diff --git a/pom.xml b/pom.xml index ba473d75..48cdf1bf 100644 --- a/pom.xml +++ b/pom.xml @@ -142,7 +142,7 @@ org.ohdsi.sql SqlRender - 1.6.8 + 1.16.1-SNAPSHOT test diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ConditionEraSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ConditionEraSqlBuilder.java index 4f6183f3..3fa1d738 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ConditionEraSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ConditionEraSqlBuilder.java @@ -35,15 +35,21 @@ protected String getQueryTemplate() { return CONDITION_ERA_TEMPLATE; } + /** + * Add params timeIntervalUnit to check for hours/minutes/seconds situation + * @param column + * @param timeIntervalUnit + * @return + */ @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.condition_concept_id"; case ERA_OCCURRENCES: return "C.condition_occurrence_count"; case DURATION: - return "(DATEDIFF(d,C.start_date, C.end_date))"; + return String.format("DATEDIFF(%s,c.start_date, c.end_date)", StringUtils.isEmpty(timeIntervalUnit) ? "d" : timeIntervalUnit); default: throw new IllegalArgumentException("Invalid CriteriaColumn for Condition Era:" + column.toString()); } diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ConditionOccurrenceSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ConditionOccurrenceSqlBuilder.java index 487d6518..1d3c98c6 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ConditionOccurrenceSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ConditionOccurrenceSqlBuilder.java @@ -40,13 +40,19 @@ protected String getQueryTemplate() { return CONDITION_OCCURRENCE_TEMPLATE; } + /** + * Add params timeIntervalUnit to check for hours/minutes/seconds situation + * @param column + * @param timeIntervalUnit + * @return + */ @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.condition_concept_id"; case DURATION: - return "(DATEDIFF(d,C.start_date, C.end_date))"; + return String.format("DATEDIFF(%s,c.start_date, c.end_date)", StringUtils.isEmpty(timeIntervalUnit) ? "d" : timeIntervalUnit); default: throw new IllegalArgumentException("Invalid CriteriaColumn for Condition Occurrence:" + column.toString()); } diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/CriteriaSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/CriteriaSqlBuilder.java index 32dd1051..9a3b6620 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/CriteriaSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/CriteriaSqlBuilder.java @@ -35,7 +35,7 @@ public String getCriteriaSql(T criteria, BuilderOptions options) { .filter((column) -> !this.getDefaultColumns().contains(column)) .collect(Collectors.toList()); if (filteredColumns.size() > 0) { - query = StringUtils.replace(query, "@additionalColumns", ", " + this.getAdditionalColumns(filteredColumns)); + query = StringUtils.replace(query, "@additionalColumns", ", " + this.getAdditionalColumnsWithTimeInterval(filteredColumns, criteria.intervalUnit)); } else { query = StringUtils.replace(query, "@additionalColumns", ""); } @@ -46,16 +46,24 @@ public String getCriteriaSql(T criteria, BuilderOptions options) { return query; } - protected abstract String getTableColumnForCriteriaColumn(CriteriaColumn column); + protected abstract String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit); protected String getAdditionalColumns(List columns) { String cols = String.join(", ", columns.stream() .map((column) -> { - return String.format("%s as %s", getTableColumnForCriteriaColumn(column), column.columnName()); + return String.format("%s as %s", getTableColumnForCriteriaColumn(column, null), column.columnName()); }).collect(Collectors.toList())); return cols; } + protected String getAdditionalColumnsWithTimeInterval(List columns, String timeIntervalUnit) { + String cols = String.join(", ", columns.stream() + .map((column) -> { + return String.format("%s as %s", getTableColumnForCriteriaColumn(column, timeIntervalUnit), column.columnName()); + }).collect(Collectors.toList())); + return cols; + } + protected abstract Set getDefaultColumns(); protected String embedSelectClauses(String query, List selectClauses) { diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DeathSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DeathSqlBuilder.java index 632c14fd..23852594 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DeathSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DeathSqlBuilder.java @@ -40,7 +40,7 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "coalesce(C.cause_concept_id,0)"; diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DeviceExposureSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DeviceExposureSqlBuilder.java index a90ee542..f5eb74f8 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DeviceExposureSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DeviceExposureSqlBuilder.java @@ -43,14 +43,15 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.device_concept_id"; case QUANTITY: return "C.quantity"; case DURATION: - return "DATEDIFF(d,c.start_date, c.end_date)"; + return String.format("DATEDIFF(%s,c.start_date, c.end_date)", StringUtils.isEmpty(timeIntervalUnit) ? "d" : timeIntervalUnit); +// return "DATEDIFF(d,c.start_date, c.end_date)"; default: throw new IllegalArgumentException("Invalid CriteriaColumn for Device Exposure:" + column.toString()); } diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DoseEraSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DoseEraSqlBuilder.java index 3f473f86..01055ca8 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DoseEraSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DoseEraSqlBuilder.java @@ -37,12 +37,12 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.drug_concept_id"; case DURATION: - return "DATEDIFF(d, C.start_date, C.end_date)"; + return String.format("DATEDIFF(%s,c.start_date, c.end_date)", StringUtils.isEmpty(timeIntervalUnit) ? "d" : timeIntervalUnit); case UNIT: return "C.unit_concept_id"; case VALUE_AS_NUMBER: diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DrugEraSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DrugEraSqlBuilder.java index acb00829..397938dc 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DrugEraSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DrugEraSqlBuilder.java @@ -38,7 +38,7 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.drug_concept_id"; diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DrugExposureSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DrugExposureSqlBuilder.java index 25665d68..eb69977d 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DrugExposureSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/DrugExposureSqlBuilder.java @@ -42,14 +42,14 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DAYS_SUPPLY: return "C.days_supply"; case DOMAIN_CONCEPT: return "C.drug_concept_id"; case DURATION: - return "DATEDIFF(d, C.start_date, C.end_date)"; + return String.format("DATEDIFF(%s,c.start_date, c.end_date)", StringUtils.isEmpty(timeIntervalUnit) ? "d" : timeIntervalUnit); case QUANTITY: return "C.quantity"; case REFILLS: diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/LocationRegionSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/LocationRegionSqlBuilder.java index f7dbd59c..48049837 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/LocationRegionSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/LocationRegionSqlBuilder.java @@ -30,7 +30,7 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.region_concept_id"; diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/MeasurementSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/MeasurementSqlBuilder.java index 8644e85b..289b8196 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/MeasurementSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/MeasurementSqlBuilder.java @@ -41,7 +41,7 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.measurement_concept_id"; diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ObservationPeriodSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ObservationPeriodSqlBuilder.java index d403be12..56629c4c 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ObservationPeriodSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ObservationPeriodSqlBuilder.java @@ -55,7 +55,7 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.period_type_concept_id"; diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ObservationSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ObservationSqlBuilder.java index ce66dda3..65fd0ce2 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ObservationSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ObservationSqlBuilder.java @@ -43,7 +43,7 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.observation_concept_id"; diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/PayerPlanPeriodSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/PayerPlanPeriodSqlBuilder.java index 6b0b5135..14a268cc 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/PayerPlanPeriodSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/PayerPlanPeriodSqlBuilder.java @@ -54,7 +54,7 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.payer_concept_id"; diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ProcedureOccurrenceSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ProcedureOccurrenceSqlBuilder.java index dc2d0c02..479e13a9 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ProcedureOccurrenceSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/ProcedureOccurrenceSqlBuilder.java @@ -41,7 +41,7 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.procedure_concept_id"; diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/SpecimenSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/SpecimenSqlBuilder.java index 32524c92..31bfd487 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/SpecimenSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/SpecimenSqlBuilder.java @@ -36,7 +36,7 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.specimen_concept_id"; diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/VisitDetailSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/VisitDetailSqlBuilder.java index a20216c7..c3224a7e 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/VisitDetailSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/VisitDetailSqlBuilder.java @@ -32,12 +32,12 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.visit_detail_concept_id"; case DURATION: - return "DATEDIFF(d, C.start_date, C.end_date)"; + return String.format("DATEDIFF(%s,c.start_date, c.end_date)", StringUtils.isEmpty(timeIntervalUnit) ? "d" : timeIntervalUnit); default: throw new IllegalArgumentException("Invalid CriteriaColumn for Visit Detail:" + column.toString()); } diff --git a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/VisitOccurrenceSqlBuilder.java b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/VisitOccurrenceSqlBuilder.java index 651cdd8d..632bb64c 100644 --- a/src/main/java/org/ohdsi/circe/cohortdefinition/builders/VisitOccurrenceSqlBuilder.java +++ b/src/main/java/org/ohdsi/circe/cohortdefinition/builders/VisitOccurrenceSqlBuilder.java @@ -34,12 +34,12 @@ protected String getQueryTemplate() { } @Override - protected String getTableColumnForCriteriaColumn(CriteriaColumn column) { + protected String getTableColumnForCriteriaColumn(CriteriaColumn column, String timeIntervalUnit) { switch (column) { case DOMAIN_CONCEPT: return "C.visit_concept_id"; case DURATION: - return "DATEDIFF(d, C.start_date, C.end_date)"; + return String.format("DATEDIFF(%s,c.start_date, c.end_date)", StringUtils.isEmpty(timeIntervalUnit) ? "d" : timeIntervalUnit); default: throw new IllegalArgumentException("Invalid CriteriaColumn for Visit Occurrence:" + column.toString()); } diff --git a/src/test/java/org/ohdsi/circe/cohortdefinition/builders/CorelatedCriteria_5_0_0_Test.java b/src/test/java/org/ohdsi/circe/cohortdefinition/builders/CorelatedCriteria_5_0_0_Test.java index dfcfbc79..21668fa2 100644 --- a/src/test/java/org/ohdsi/circe/cohortdefinition/builders/CorelatedCriteria_5_0_0_Test.java +++ b/src/test/java/org/ohdsi/circe/cohortdefinition/builders/CorelatedCriteria_5_0_0_Test.java @@ -14,11 +14,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.ohdsi.circe.AbstractDatabaseTest; -import org.ohdsi.circe.cohortdefinition.CohortExpressionQueryBuilder; -import org.ohdsi.circe.cohortdefinition.ConditionOccurrence; -import org.ohdsi.circe.cohortdefinition.CorelatedCriteria; -import org.ohdsi.circe.cohortdefinition.CriteriaGroup; -import org.ohdsi.circe.cohortdefinition.Occurrence; +import org.ohdsi.circe.cohortdefinition.*; import org.ohdsi.sql.SqlRender; import org.ohdsi.sql.SqlTranslate; import org.slf4j.Logger; @@ -193,6 +189,53 @@ public void distinctVisitTest() throws Exception { } + @Test + public void distinctVisitTestWithTimeInterval() throws Exception { + final CohortExpressionQueryBuilder queryBuilder = new CohortExpressionQueryBuilder(); + final String RESULTS_SCHEMA = "distinct_visit"; + final String[] testDataSetsPrep = new String[] { "/datasets/vocabulary.json", + "/corelatedcriteria/distinctVisit_PREP.json"}; + + // Load expected data from an XML dataset + final String[] testDataSetsVerify = new String[] {"/corelatedcriteria/distinctVisit_VERIFY.json"}; + final IDataSet expectedDataSet = DataSetFactory.createDataSet(testDataSetsVerify); + + // prepare results schema for the specified options.resultSchema + prepareSchema(RESULTS_SCHEMA, RESULTS_DDL_PATH); + + final IDatabaseConnection dbUnitCon = getConnection(); + + // load test data into DB. + final IDataSet dsPrep = DataSetFactory.createDataSet(testDataSetsPrep); + DatabaseOperation.CLEAN_INSERT.execute(dbUnitCon, dsPrep); // clean load of the DB. Careful, clean means "delete the old stuff" + + /// build inclusion query for Group Criteria + CriteriaGroup cg = new CriteriaGroup(); + cg.type= "ALL"; + CorelatedCriteria cc = new CorelatedCriteria(); + cc.criteria = new ConditionOccurrence(); // find any condition occurence + cc.criteria.intervalUnit = IntervalUnit.HOUR.getName(); + cc.startWindow = CriteriaUtils.getPrior365Window(); + cc.occurrence = CriteriaUtils.getDistinctCount(CriteriaColumn.VISIT_ID, Occurrence.AT_LEAST, 2); + cg.criteriaList = new CorelatedCriteria[] { cc }; + + // translate to PG + String eventTable = String.format(CriteriaUtils.EVENT_TABLE_TEMPLATE, RESULTS_SCHEMA + ".cohort", "cdm", 1); + String countQuery = queryBuilder.getCriteriaGroupQuery(cg, eventTable); + String translatedCountQuery = SqlRender.renderSql(SqlTranslate.translateSql(countQuery, "postgresql"), + new String[] {"cdm_database_schema", "indexId"}, + new String[] {"cdm", "0"}); + + // Validate results + // perform inclusion query + final ITable actualInclusion = dbUnitCon.createQueryTable(RESULTS_SCHEMA + ".output", translatedCountQuery); + final ITable expectedInclusion = expectedDataSet.getTable(RESULTS_SCHEMA + ".output"); + + // Assert actual database table match expected table + Assertion.assertEquals(expectedInclusion, actualInclusion); + + } + @Test public void distinctDefaultTest() throws Exception { final CohortExpressionQueryBuilder queryBuilder = new CohortExpressionQueryBuilder(); diff --git a/src/test/java/org/ohdsi/circe/cohortdefinition/builders/WindowCriteria_5_0_0_Test.java b/src/test/java/org/ohdsi/circe/cohortdefinition/builders/WindowCriteria_5_0_0_Test.java index 13a6137c..5776d01a 100644 --- a/src/test/java/org/ohdsi/circe/cohortdefinition/builders/WindowCriteria_5_0_0_Test.java +++ b/src/test/java/org/ohdsi/circe/cohortdefinition/builders/WindowCriteria_5_0_0_Test.java @@ -115,22 +115,6 @@ public void windowConditionEraTest() throws Exception { } - @Test - public void windowConditionEraTestInHourInterval() throws Exception { - - final String resultsSchema = "window_condition_era"; - final String[] testDataSetsPrep = new String[]{"/datasets/vocabulary.json", - "/windowcriteria/windowConditionEra_PREP.json"}; - final String[] testDataSetsVerify = new String[]{"/windowcriteria/windowConditionEra_VERIFY.json"}; - WindowedCriteria wc = new WindowedCriteria(); - wc.criteria = new ConditionEra(); // find any condition era - wc.startWindow = CriteriaUtils.getPrior365WindowTimeUnitInterval(IntervalUnit.HOUR.getName()); - List additionalColumns = Arrays.asList(CriteriaColumn.START_DATE, CriteriaColumn.END_DATE, CriteriaColumn.DOMAIN_CONCEPT, - CriteriaColumn.ERA_OCCURRENCES, CriteriaColumn.DURATION); - this.performWindowTest(wc, resultsSchema, testDataSetsPrep, testDataSetsVerify, additionalColumns); - - } - @Test public void windowConditionOccurrenceTest() throws Exception { @@ -181,10 +165,11 @@ public void windowDeathTestInSecondInterval() throws Exception { final String resultsSchema = "window_death"; final String[] testDataSetsPrep = new String[]{"/datasets/vocabulary.json", - "/windowcriteria/windowDeath_PREP.json"}; - final String[] testDataSetsVerify = new String[]{"/windowcriteria/windowDeath_VERIFY.json"}; + "/windowcriteria/windowDeathTimeInterval_PREP.json"}; + final String[] testDataSetsVerify = new String[]{"/windowcriteria/windowDeathTimeInterval_VERIFY.json"}; WindowedCriteria wc = new WindowedCriteria(); wc.criteria = new Death(); // find any death + wc.criteria.intervalUnit = IntervalUnit.SECOND.getName(); wc.startWindow = CriteriaUtils.getPrior365WindowTimeUnitInterval(IntervalUnit.SECOND.getName()); List additionalColumns = Arrays.asList(CriteriaColumn.START_DATE, CriteriaColumn.END_DATE, CriteriaColumn.DOMAIN_CONCEPT, CriteriaColumn.DURATION); this.performWindowTest(wc, resultsSchema, testDataSetsPrep, testDataSetsVerify, additionalColumns); @@ -206,6 +191,20 @@ public void windowDeviceExposureTest() throws Exception { } + @Test + public void windowDeviceExposureTestInHourInterval() throws Exception { + final String resultsSchema = "window_device_exposure"; + final String[] testDataSetsPrep = new String[]{"/datasets/vocabulary.json", + "/windowcriteria/windowDeviceExposureTimeInterval_PREP.json"}; + final String[] testDataSetsVerify = new String[]{"/windowcriteria/windowDeviceExposureTimeInterval_VERIFY.json"}; + WindowedCriteria wc = new WindowedCriteria(); + wc.criteria = new DeviceExposure(); // find any device exposure + wc.criteria.intervalUnit = IntervalUnit.HOUR.getName(); + wc.startWindow = CriteriaUtils.getPrior365WindowTimeUnitInterval(IntervalUnit.HOUR.getName()); + List additionalColumns = Arrays.asList(CriteriaColumn.START_DATE, CriteriaColumn.END_DATE, CriteriaColumn.DOMAIN_CONCEPT, CriteriaColumn.QUANTITY, CriteriaColumn.DURATION); + this.performWindowTest(wc, resultsSchema, testDataSetsPrep, testDataSetsVerify, additionalColumns); + } + @Test public void windowDoseEraTest() throws Exception { @@ -254,6 +253,20 @@ public void windowDrugExposureTest() throws Exception { } + @Test + public void windowDrugExposureTestInMinuteInterval() throws Exception { + final String resultsSchema = "window_drug_exposure"; + final String[] testDataSetsPrep = new String[]{"/datasets/vocabulary.json", "/windowcriteria/windowDrugExposureTimeInterval_PREP.json"}; + final String[] testDataSetsVerify = new String[]{"/windowcriteria/windowDrugExposureTimeInterval_VERIFY.json"}; + WindowedCriteria wc = new WindowedCriteria(); + wc.criteria = new DrugExposure(); // find any drug exposure + wc.criteria.intervalUnit = IntervalUnit.MINUTE.getName(); + wc.startWindow = CriteriaUtils.getPrior365WindowTimeUnitInterval(IntervalUnit.MINUTE.getName()); + List additionalColumns = Arrays.asList(CriteriaColumn.START_DATE, CriteriaColumn.END_DATE, + CriteriaColumn.DOMAIN_CONCEPT, CriteriaColumn.REFILLS, CriteriaColumn.QUANTITY, CriteriaColumn.DAYS_SUPPLY, CriteriaColumn.DURATION); + this.performWindowTest(wc, resultsSchema, testDataSetsPrep, testDataSetsVerify, additionalColumns); + } + @Test public void windowMeasurementTest() throws Exception { diff --git a/src/test/java/org/ohdsi/circe/cohortdefinition/builders/WindowCriteria_5_3_0_Test.java b/src/test/java/org/ohdsi/circe/cohortdefinition/builders/WindowCriteria_5_3_0_Test.java index a7614636..37a25255 100644 --- a/src/test/java/org/ohdsi/circe/cohortdefinition/builders/WindowCriteria_5_3_0_Test.java +++ b/src/test/java/org/ohdsi/circe/cohortdefinition/builders/WindowCriteria_5_3_0_Test.java @@ -114,4 +114,18 @@ public void windowVisitDetailTest() throws Exception { List additionalColumns = Arrays.asList(CriteriaColumn.START_DATE, CriteriaColumn.END_DATE, CriteriaColumn.DOMAIN_CONCEPT, CriteriaColumn.DURATION); this.performWindowTest(wc, resultsSchema, testDataSetsPrep, testDataSetsVerify, additionalColumns); } + + @Test + public void windowVisitDetailTestInSecondInterval() throws Exception { + final String resultsSchema = "window_visit_detail"; + final String[] testDataSetsPrep = new String[]{"/datasets/vocabulary.json", + "/windowcriteria/windowVisitDetailTimeInterval_PREP.json"}; + final String[] testDataSetsVerify = new String[]{"/windowcriteria/windowVisitDetailTimeInterval_VERIFY.json"}; + WindowedCriteria wc = new WindowedCriteria(); + wc.criteria = new VisitDetail(); // find any visit detail + wc.criteria.intervalUnit = IntervalUnit.SECOND.getName(); + wc.startWindow = CriteriaUtils.getPrior365WindowTimeUnitInterval(IntervalUnit.SECOND.getName()); + List additionalColumns = Arrays.asList(CriteriaColumn.START_DATE, CriteriaColumn.END_DATE, CriteriaColumn.DOMAIN_CONCEPT, CriteriaColumn.DURATION); + this.performWindowTest(wc, resultsSchema, testDataSetsPrep, testDataSetsVerify, additionalColumns); + } } diff --git a/src/test/resources/ddl/cdm_v5.0.sql b/src/test/resources/ddl/cdm_v5.0.sql index eae1cbb0..0eb1dad8 100644 --- a/src/test/resources/ddl/cdm_v5.0.sql +++ b/src/test/resources/ddl/cdm_v5.0.sql @@ -194,6 +194,7 @@ CREATE TABLE @schemaName.death ( person_id INTEGER NOT NULL , death_date DATE NOT NULL , + death_datetime TIMESTAMP NULL , death_type_concept_id INTEGER NOT NULL , cause_concept_id INTEGER NULL , cause_source_value VARCHAR(50) NULL, @@ -243,7 +244,9 @@ CREATE TABLE @schemaName.drug_exposure person_id INTEGER NOT NULL , drug_concept_id INTEGER NOT NULL , drug_exposure_start_date DATE NOT NULL , + drug_exposure_start_datetime TIMESTAMP NULL , drug_exposure_end_date DATE NULL , + drug_exposure_end_datetime TIMESTAMP NULL , drug_type_concept_id INTEGER NOT NULL , stop_reason VARCHAR(20) NULL , refills INTEGER NULL , @@ -269,7 +272,9 @@ CREATE TABLE @schemaName.device_exposure person_id INTEGER NOT NULL , device_concept_id INTEGER NOT NULL , device_exposure_start_date DATE NOT NULL , + device_exposure_start_datetime TIMESTAMP NULL , device_exposure_end_date DATE NULL , + device_exposure_end_datetime TIMESTAMP NULL , device_type_concept_id INTEGER NOT NULL , unique_device_id VARCHAR(50) NULL , quantity INTEGER NULL , @@ -540,7 +545,9 @@ CREATE TABLE @schemaName.dose_era unit_concept_id INTEGER NOT NULL , dose_value NUMERIC NOT NULL , dose_era_start_date DATE NOT NULL , - dose_era_end_date DATE NOT NULL + dose_era_start_datetime TIMESTAMP NULL , + dose_era_end_date DATE NOT NULL , + dose_era_end_datetime TIMESTAMP NULL ) ; diff --git a/src/test/resources/windowcriteria/windowDeathTimeInterval_PREP.json b/src/test/resources/windowcriteria/windowDeathTimeInterval_PREP.json new file mode 100644 index 00000000..fda75392 --- /dev/null +++ b/src/test/resources/windowcriteria/windowDeathTimeInterval_PREP.json @@ -0,0 +1,65 @@ +{ + "cdm.person": [ + { + "person_id": 1, + "gender_concept_id": 0, + "year_of_birth": 0, + "race_concept_id": 0, + "ethnicity_concept_id": 0 + } + ], + "cdm.death": [ + { + "person_id": 1, + "cause_concept_id": 2, + "death_type_concept_id": 0, + "death_date": "2000-01-01", + "death_datetime": "2000-01-01 00:00:00" + }, + { + "person_id": 1, + "cause_concept_id": 2, + "death_type_concept_id": 0, + "death_date": "2005-01-01", + "death_datetime": "2005-01-01 00:00:00" + }, + { + "person_id": 1, + "cause_concept_id": 2, + "death_type_concept_id": 0, + "death_date": "2005-02-01", + "death_datetime": "2005-02-01 00:00:00" + }, + { + "person_id": 1, + "cause_concept_id": 2, + "death_type_concept_id": 0, + "death_date": "2005-03-01", + "death_datetime": "2005-03-01 00:00:00" + }, + { + "person_id": 1, + "cause_concept_id": 2, + "death_type_concept_id": 0, + "death_date": "2005-04-01", + "death_datetime": "2005-04-01 00:00:00" + } + ], + "cdm.observation_period": [ + { + "observation_period_id": 1, + "person_id": 1, + "observation_period_start_date": "2000-01-01", + "observation_period_end_date": "2010-01-01", + "period_type_concept_id": 0 + } + ], + "window_death.cohort": [ + { + "cohort_definition_id": 1, + "subject_id": 1, + "cohort_start_date": "2006-01-01", + "cohort_end_date": "2006-01-01" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/windowcriteria/windowDeathTimeInterval_VERIFY.json b/src/test/resources/windowcriteria/windowDeathTimeInterval_VERIFY.json new file mode 100644 index 00000000..d3212c46 --- /dev/null +++ b/src/test/resources/windowcriteria/windowDeathTimeInterval_VERIFY.json @@ -0,0 +1,54 @@ +{ + "window_death.no_columns": [ + { + "person_id": 1, + "event_id": 1 + }, + { + "person_id": 1, + "event_id": 1 + }, + { + "person_id": 1, + "event_id": 1 + }, + { + "person_id": 1, + "event_id": 1 + } + ], + "window_death.add_columns": [ + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-01-01", + "end_date": "2005-01-01 00:00:00.0", + "domain_concept_id": 2, + "duration": 1 + }, + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-02-01", + "end_date": "2005-02-01 00:00:00.0", + "domain_concept_id": 2, + "duration": 1 + }, + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-03-01", + "end_date": "2005-03-01 00:00:00.0", + "domain_concept_id": 2, + "duration": 1 + }, + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-04-01", + "end_date": "2005-04-01 00:00:00.0", + "domain_concept_id": 2, + "duration": 1 + } + ] +} \ No newline at end of file diff --git a/src/test/resources/windowcriteria/windowDeviceExposureTimeInterval_PREP.json b/src/test/resources/windowcriteria/windowDeviceExposureTimeInterval_PREP.json new file mode 100644 index 00000000..aa89f07c --- /dev/null +++ b/src/test/resources/windowcriteria/windowDeviceExposureTimeInterval_PREP.json @@ -0,0 +1,79 @@ +{ + "cdm.person": [ + { + "person_id": 1, + "gender_concept_id": 0, + "year_of_birth": 0, + "race_concept_id": 0, + "ethnicity_concept_id": 0 + } + ], + "cdm.device_exposure": [ + { + "device_exposure_id": 1, + "person_id": 1, + "device_concept_id": 2, + "device_type_concept_id": 0, + "device_exposure_start_date": "2000-01-01", + "device_exposure_start_datetime": "2000-01-01 00:00:00", + "quantity": 1 + }, + { + "device_exposure_id": 2, + "person_id": 1, + "device_concept_id": 2, + "device_type_concept_id": 0, + "device_exposure_start_date": "2005-01-01", + "device_exposure_start_datetime": "2005-01-01 00:00:00", + "device_exposure_end_datetime": "2005-01-01 00:30:00", + "quantity": 2 + }, + { + "device_exposure_id": 3, + "person_id": 1, + "device_concept_id": 2, + "device_type_concept_id": 0, + "device_exposure_start_date": "2005-02-01", + "device_exposure_start_datetime": "2005-02-01 00:00:00", + "device_exposure_end_datetime": "2005-02-01 01:00:00", + "quantity": 3 + }, + { + "device_exposure_id": 4, + "person_id": 1, + "device_concept_id": 2, + "device_type_concept_id": 0, + "device_exposure_start_date": "2005-03-01", + "device_exposure_start_datetime": "2005-03-01 00:00:00", + "device_exposure_end_datetime": "2005-03-02 00:00:00", + "quantity": 4 + }, + { + "device_exposure_id": 5, + "person_id": 1, + "device_concept_id": 2, + "device_type_concept_id": 0, + "device_exposure_start_date": "2005-04-01", + "device_exposure_start_datetime": "2005-04-01 00:00:00", + "device_exposure_end_datetime": "2005-05-01 00:00:00", + "quantity": 5 + } + ], + "cdm.observation_period": [ + { + "observation_period_id": 1, + "person_id": 1, + "observation_period_start_date": "2000-01-01", + "observation_period_end_date": "2010-01-01", + "period_type_concept_id": 0 + } + ], + "window_device_exposure.cohort": [ + { + "cohort_definition_id": 1, + "subject_id": 1, + "cohort_start_date": "2006-01-01", + "cohort_end_date": "2006-01-01" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/windowcriteria/windowDeviceExposureTimeInterval_VERIFY.json b/src/test/resources/windowcriteria/windowDeviceExposureTimeInterval_VERIFY.json new file mode 100644 index 00000000..910656fb --- /dev/null +++ b/src/test/resources/windowcriteria/windowDeviceExposureTimeInterval_VERIFY.json @@ -0,0 +1,58 @@ +{ + "window_device_exposure.no_columns": [ + { + "person_id": 1, + "event_id": 1 + }, + { + "person_id": 1, + "event_id": 1 + }, + { + "person_id": 1, + "event_id": 1 + }, + { + "person_id": 1, + "event_id": 1 + } + ], + "window_device_exposure.add_columns": [ + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-01-01 00:00:00", + "end_date": "2005-01-01 00:30:00", + "domain_concept_id": 2, + "quantity": 2, + "duration": 0.5 + }, + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-02-01 00:00:00", + "end_date": "2005-02-01 01:00:00", + "domain_concept_id": 2, + "quantity": 3, + "duration": 1 + }, + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-03-01", + "end_date": "2005-03-02", + "domain_concept_id": 2, + "quantity": 4, + "duration": 24 + }, + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-04-01 00:00:00", + "end_date": "2005-05-01 00:00:00", + "domain_concept_id": 2, + "quantity": 5, + "duration": 720 + } + ] +} \ No newline at end of file diff --git a/src/test/resources/windowcriteria/windowDrugExposureTimeInterval_PREP.json b/src/test/resources/windowcriteria/windowDrugExposureTimeInterval_PREP.json new file mode 100644 index 00000000..dd430dfe --- /dev/null +++ b/src/test/resources/windowcriteria/windowDrugExposureTimeInterval_PREP.json @@ -0,0 +1,95 @@ +{ + "cdm.person": [ + { + "person_id": 1, + "gender_concept_id": 0, + "year_of_birth": 0, + "race_concept_id": 0, + "ethnicity_concept_id": 0 + } + ], + "cdm.drug_exposure": [ + { + "drug_exposure_id": 1, + "person_id": 1, + "drug_concept_id": 2, + "drug_type_concept_id": 0, + "refills": 1, + "quantity": 10, + "days_supply": 3, + "drug_exposure_start_date": "2000-01-01", + "drug_exposure_start_datetime": "2000-01-01 00:00:00", + "drug_exposure_end_date": "2000-01-01", + "drug_exposure_end_datetime": "2000-01-01 10:00:00" + }, + { + "drug_exposure_id": 2, + "person_id": 1, + "drug_concept_id": 2, + "drug_type_concept_id": 0, + "refills": 2, + "quantity": 11, + "days_supply": 6, + "drug_exposure_start_date": "2005-01-01", + "drug_exposure_start_datetime": "2005-01-01 00:00:00", + "drug_exposure_end_date": "2005-01-07", + "drug_exposure_end_datetime": "2005-01-01 00:10:00" + }, + { + "drug_exposure_id": 3, + "person_id": 1, + "drug_concept_id": 2, + "drug_type_concept_id": 0, + "refills": 3, + "quantity": 12, + "days_supply": 9, + "drug_exposure_start_date": "2005-02-01", + "drug_exposure_start_datetime": "2005-02-01 00:00:00", + "drug_exposure_end_date": "2005-02-07", + "drug_exposure_end_datetime": "2005-02-02 23:00:00" + }, + { + "drug_exposure_id": 4, + "person_id": 1, + "drug_concept_id": 2, + "drug_type_concept_id": 0, + "refills": 4, + "quantity": 13, + "days_supply": 12, + "drug_exposure_start_date": "2005-03-01", + "drug_exposure_start_datetime": "2005-03-01 00:00:00", + "drug_exposure_end_date": "2005-03-07", + "drug_exposure_end_datetime": "2005-03-01 01:00:00" + }, + { + "drug_exposure_id": 5, + "person_id": 1, + "drug_concept_id": 2, + "drug_type_concept_id": 0, + "refills": 5, + "quantity": 14, + "days_supply": 15, + "drug_exposure_start_date": "2005-04-01", + "drug_exposure_start_datetime": "2005-04-01 00:00:00", + "drug_exposure_end_date": "2005-04-07", + "drug_exposure_end_datetime": "2005-04-07 00:00:00" + } + ], + "cdm.observation_period": [ + { + "observation_period_id": 1, + "person_id": 1, + "observation_period_start_date": "2000-01-01", + "observation_period_end_date": "2010-01-01", + "period_type_concept_id": 0 + } + ], + "window_drug_exposure.cohort": [ + { + "cohort_definition_id": 1, + "subject_id": 1, + "cohort_start_date": "2006-01-01", + "cohort_end_date": "2006-01-01" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/windowcriteria/windowDrugExposureTimeInterval_VERIFY.json b/src/test/resources/windowcriteria/windowDrugExposureTimeInterval_VERIFY.json new file mode 100644 index 00000000..0af1f199 --- /dev/null +++ b/src/test/resources/windowcriteria/windowDrugExposureTimeInterval_VERIFY.json @@ -0,0 +1,66 @@ +{ + "window_drug_exposure.no_columns": [ + { + "person_id": 1, + "event_id": 1 + }, + { + "person_id": 1, + "event_id": 1 + }, + { + "person_id": 1, + "event_id": 1 + }, + { + "person_id": 1, + "event_id": 1 + } + ], + "window_drug_exposure.add_columns": [ + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-01-01 00:00:00", + "end_date": "2005-01-01 00:10:00", + "domain_concept_id": 2, + "refills": 2, + "quantity": 11, + "days_supply": 6, + "duration": 10 + }, + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-02-01 00:00:00", + "end_date": "2005-02-02 23:00:00", + "domain_concept_id": 2, + "refills": 3, + "quantity": 12, + "days_supply": 9, + "duration": 2820 + }, + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-03-01 00:00:00", + "end_date": "2005-03-01 01:00:00", + "domain_concept_id": 2, + "refills": 4, + "quantity": 13, + "days_supply": 12, + "duration": 60 + }, + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-04-01 00:00:00", + "end_date": "2005-04-07 00:00:00", + "domain_concept_id": 2, + "refills": 5, + "quantity": 14, + "days_supply": 15, + "duration": 8640 + } + ] +} \ No newline at end of file diff --git a/src/test/resources/windowcriteria/windowVisitDetailTimeInterval_PREP.json b/src/test/resources/windowcriteria/windowVisitDetailTimeInterval_PREP.json new file mode 100644 index 00000000..99c37539 --- /dev/null +++ b/src/test/resources/windowcriteria/windowVisitDetailTimeInterval_PREP.json @@ -0,0 +1,125 @@ +{ + "cdm.person": [ + { + "person_id":1, + "gender_concept_id":0, + "year_of_birth":0, + "race_concept_id":0, + "ethnicity_concept_id":0 + } + ], + "cdm.visit_occurrence": [ + { + "visit_occurrence_id": 1, + "person_id":1, + "visit_concept_id":2, + "visit_type_concept_id":0, + "visit_start_date":"2000-01-01", + "visit_end_date":"2000-01-07" + }, + { + "visit_occurrence_id": 2, + "person_id":1, + "visit_concept_id":2, + "visit_type_concept_id":0, + "visit_start_date":"2005-01-01", + "visit_end_date":"2005-01-07" + }, + { + "visit_occurrence_id": 3, + "person_id":1, + "visit_concept_id":2, + "visit_type_concept_id":0, + "visit_start_date":"2005-02-01", + "visit_end_date":"2005-02-07" + }, + { + "visit_occurrence_id": 4, + "person_id":1, + "visit_concept_id":2, + "visit_type_concept_id":0, + "visit_start_date":"2005-03-01", + "visit_end_date":"2005-03-07" + }, + { + "visit_occurrence_id": 5, + "person_id":1, + "visit_concept_id":2, + "visit_type_concept_id":0, + "visit_start_date":"2005-04-01", + "visit_end_date":"2005-04-07" + } + ], + "cdm.visit_detail": [ + { + "visit_detail_id": 1, + "person_id":1, + "visit_detail_concept_id":2, + "visit_detail_type_concept_id":0, + "visit_detail_start_date":"2000-01-01", + "visit_detail_end_date":"2000-01-07", + "visit_occurrence_id": 1 + }, + { + "visit_detail_id": 2, + "person_id":1, + "visit_detail_concept_id":2, + "visit_detail_type_concept_id":0, + "visit_detail_start_date":"2005-01-01", + "visit_detail_start_datetime":"2005-01-01 00:00:00", + "visit_detail_end_date":"2005-01-07", + "visit_detail_end_datetime":"2005-01-01 00:00:05", + "visit_occurrence_id": 2 + }, + { + "visit_detail_id": 3, + "person_id":1, + "visit_detail_concept_id":2, + "visit_detail_type_concept_id":0, + "visit_detail_start_date":"2005-02-01", + "visit_detail_start_datetime":"2005-02-01 00:00:00", + "visit_detail_end_date":"2005-02-07", + "visit_detail_end_datetime":"2005-02-01 00:05:00", + "visit_occurrence_id": 3 + }, + { + "visit_detail_id": 4, + "person_id":1, + "visit_detail_concept_id":2, + "visit_detail_type_concept_id":0, + "visit_detail_start_date":"2005-03-01", + "visit_detail_start_datetime":"2005-03-01 00:00:00", + "visit_detail_end_date":"2005-03-07", + "visit_detail_end_datetime":"2005-03-01 05:00:00", + "visit_occurrence_id": 4 + }, + { + "visit_detail_id": 5, + "person_id":1, + "visit_detail_concept_id":2, + "visit_detail_type_concept_id":0, + "visit_detail_start_date":"2005-04-01", + "visit_detail_start_datetime":"2005-04-01 00:00:00", + "visit_detail_end_date":"2005-04-07", + "visit_detail_end_datetime":"2005-04-05 00:00:00", + "visit_occurrence_id": 5 + } + ], + "cdm.observation_period" : [ + { + "observation_period_id": 1, + "person_id":1, + "observation_period_start_date":"2000-01-01", + "observation_period_end_date":"2010-01-01", + "period_type_concept_id": 0 + } + ], + "window_visit_detail.cohort" : [ + { + "cohort_definition_id": 1, + "subject_id":1, + "cohort_start_date":"2006-01-01", + "cohort_end_date":"2006-01-01" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/windowcriteria/windowVisitDetailTimeInterval_VERIFY.json b/src/test/resources/windowcriteria/windowVisitDetailTimeInterval_VERIFY.json new file mode 100644 index 00000000..14ce5d32 --- /dev/null +++ b/src/test/resources/windowcriteria/windowVisitDetailTimeInterval_VERIFY.json @@ -0,0 +1,54 @@ +{ + "window_visit_detail.no_columns": [ + { + "person_id": 1, + "event_id": 1 + }, + { + "person_id": 1, + "event_id": 1 + }, + { + "person_id": 1, + "event_id": 1 + }, + { + "person_id": 1, + "event_id": 1 + } + ], + "window_visit_detail.add_columns": [ + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-01-01 00:00:00", + "end_date": "2005-01-01 00:00:05", + "domain_concept_id": 2, + "duration": 5 + }, + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-02-01 00:00:00", + "end_date": "2005-02-01 00:05:00", + "domain_concept_id": 2, + "duration": 300 + }, + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-03-01 00:00:00", + "end_date": "2005-03-01 05:00:00", + "domain_concept_id": 2, + "duration": 18000 + }, + { + "person_id": 1, + "event_id": 1, + "start_date": "2005-04-01 00:00:00", + "end_date": "2005-04-05 00:00:00", + "domain_concept_id": 2, + "duration": 345600 + } + ] +} \ No newline at end of file