Skip to content

Commit

Permalink
Revert "fix"
Browse files Browse the repository at this point in the history
This reverts commit f819d5e.
  • Loading branch information
jcnamendiOdysseus committed Jan 16, 2024
1 parent ca6bbfd commit cebb8c5
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.ohdsi.circe.cohortdefinition.CohortExpression;
import org.ohdsi.circe.cohortdefinition.DateOffsetStrategy;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

import static org.ohdsi.circe.check.operations.Operations.match;
Expand All @@ -41,9 +43,9 @@ protected WarningSeverity defineSeverity() {
protected void check(CohortExpression expression, WarningReporter reporter) {

match(expression.endStrategy)
.isA(DateOffsetStrategy.class)
.then(s -> match((DateOffsetStrategy)s)
.when(dateOffsetStrategy -> Objects.equals(StartDate, dateOffsetStrategy.dateField) && (0 == dateOffsetStrategy.offsetUnitValue || 0 == dateOffsetStrategy.offset))
.then(dateOffsetStrategy -> reporter.add(String.format(DAYS_OFFSET_WARNING, dateOffsetStrategy.offsetUnit))));
.isA(DateOffsetStrategy.class)
.then(s -> match((DateOffsetStrategy)s)
.when(dateOffsetStrategy -> Objects.equals(StartDate, dateOffsetStrategy.dateField) && 0 == dateOffsetStrategy.offsetUnitValue)
.then(dateOffsetStrategy -> reporter.add(String.format(DAYS_OFFSET_WARNING, dateOffsetStrategy.offsetUnit))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ protected void checkCriteria(CorelatedCriteria criteria, String groupName, Warni
String name = CriteriaNameHelper.getCriteriaName(criteria.criteria) + " at " + groupName;
Execution addWarning = () -> reporter.add(WARNING, name);
match(criteria)
.when(c -> c.startWindow != null && ((c.startWindow.start != null && c.startWindow.start.days != null)
|| (c.startWindow.end != null && c.startWindow.end.days != null))
|| c.startWindow != null && ((c.startWindow.start != null && c.startWindow.start.timeUnitValue != null)
|| (c.startWindow.end != null) && c.startWindow.end.timeUnitValue != null))
.when(c -> c.startWindow != null && ((c.startWindow.start != null && c.startWindow.start.days != null)
|| (c.startWindow.end != null && c.startWindow.end.days != null))
|| c.startWindow != null && (( c.startWindow.start != null && c.startWindow.start.timeUnitValue != null)
|| (c.startWindow.end != null) && c.startWindow.end.timeUnitValue != null))
.then(cc -> match(cc.criteria)
.isA(ConditionEra.class)
.then(c -> match((ConditionEra)c)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
*/
package org.ohdsi.circe.cohortdefinition;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
*
* @author Chris Knoll <[email protected]>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class CustomEraStrategy extends EndStrategy {

@JsonProperty("DrugCodesetId")
Expand All @@ -34,19 +32,17 @@ public class CustomEraStrategy extends EndStrategy {
@JsonProperty("GapDays")
public int gapDays = 0;
@JsonProperty("GapUnit")
public String gapUnit = IntervalUnit.DAY.getName();;
public String gapUnit = "day";
@JsonProperty("GapUnitValue")
public Integer gapUnitValue = null;
public int gapUnitValue = 0;

@JsonProperty("Offset")
public int offset = 0;
@JsonProperty("OffsetUnit")
public String offsetUnit = IntervalUnit.DAY.getName();;
public String offsetUnit = "day";
@JsonProperty("OffsetUnitValue")
public int offsetUnitValue = 0;



@JsonProperty("DaysSupplyOverride")
public Integer daysSupplyOverride = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,22 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class DateOffsetStrategy extends EndStrategy {

public enum DateField {
StartDate,
EndDate
}

@JsonProperty("DateField")
public DateField dateField = DateField.StartDate;

@JsonProperty("Offset")
public int offset = 0;

@JsonProperty("OffsetUnit")
public String offsetUnit = IntervalUnit.DAY.getName();;
@JsonProperty("DateField")
public DateField dateField = DateField.StartDate;
@JsonProperty("OffsetUnitValue")
public int offsetUnitValue = 0;
@JsonProperty("OffsetUnit")
public String offsetUnit = "day";

@Override
public String accept(IGetEndStrategySqlDispatcher dispatcher, String eventTable) {
return dispatcher.getStrategySql(this, eventTable);
}

public enum DateField {
StartDate,
EndDate
}
}
33 changes: 14 additions & 19 deletions src/main/java/org/ohdsi/circe/cohortdefinition/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,25 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class Window {

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonProperty("Start")
public Endpoint start;
@JsonProperty("End")
public Endpoint end;
@JsonProperty("UseIndexEnd")
public Boolean useIndexEnd;
@JsonProperty("UseEventEnd")
public Boolean useEventEnd;

public static class Endpoint {

@JsonProperty("Days")
public Integer days;

@JsonProperty("Coeff")
public int coeff;
@JsonProperty("TimeUnitValue")
public Integer timeUnitValue;

@JsonProperty("TimeUnit")
public String timeUnit = IntervalUnit.DAY.getName();
}

@JsonProperty("Start")
public Endpoint start;

@JsonProperty("End")
public Endpoint end;
public String timeUnit = "day";

@JsonProperty("UseIndexEnd")
public Boolean useIndexEnd;

@JsonProperty("UseEventEnd")
public Boolean useEventEnd;

@JsonProperty("Coeff")
public int coeff;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
-- date offset strategy

select event_id, person_id,
case when DATEADD(@offsetUnit,@offsetUnitValue,@dateField) > op_end_date then op_end_date else DATEADD(@offsetUnit,@offsetUnitValue,@dateField) end as end_date
select event_id,
person_id,
case
when DATEADD(@offsetUnit, @offsetUnitValue, @dateField) > op_end_date then op_end_date
else DATEADD(@offsetUnit, @offsetUnitValue, @dateField) end as end_date
INTO #strategy_ends
from @eventTable;
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ from ( --cteEnds
FROM #cohort_rows c
JOIN ( -- cteEndDates
SELECT
person_id
, DATEADD(@eraPadUnit,-1 * @eraPadValue, event_date) as end_date
person_id,
DATEADD(@era_pad_unit, -1 * @eraconstructorpad, event_date) as end_date
FROM
(
SELECT
Expand All @@ -83,7 +83,7 @@ from ( --cteEnds

SELECT
person_id
, DATEADD(@eraPadUnit,@eraPadValue,end_date) as end_date
, DATEADD(@era_pad_unit, -1 * @eraconstructorpad, end_date) as end_date
, 1 AS event_type
FROM #cohort_rows
) RAWDATA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public void checkCorrect() {
List<Warning> warnings = check.check(CORRECT_EXPRESSION);
assertEquals(0, warnings.size());
}
@Test
public void checkCorrectSecond() {
List<Warning> warnings = check.check(CORRECT_EXPRESSION_SECOND);
assertEquals(0, warnings.size());
}
@Test
public void checkCorrectSecond() {
List<Warning> warnings = check.check(CORRECT_EXPRESSION_SECOND);
assertEquals(0, warnings.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public void customEraExitTestSecond() {
));

}

@Test
public void conceptSetSimpleTest() {
CohortExpression expression = CohortExpression.fromJson(ResourceHelper.GetResourceAsString("/printfriendly/conceptSet_simple.json"));
Expand Down Expand Up @@ -671,7 +671,7 @@ public void nullConceptSetListTest() {
pf.renderConceptSetList((ConceptSet[])null);

}

@Test
public void dateAdjustTest() {
CohortExpression expression = CohortExpression.fromJson(ResourceHelper.GetResourceAsString("/printfriendly/dateAdjust.json"));
Expand All @@ -690,16 +690,16 @@ public void dateAdjustTest() {
"12. visit occurrences of 'Concept Set 1', starting 10 days after and ending 20 days after the event start date.",
"13. visit details of 'Concept Set 1', starting 10 days after and ending 20 days after the event start date."
));

}

@Test
public void emptyConceptListTest() {
CohortExpression expression = CohortExpression.fromJson(ResourceHelper.GetResourceAsString("/printfriendly/emptyConceptList.json"));
String markdown = pf.renderCohort(expression);
assertThat(markdown, stringContainsInOrder(
"1. condition occurrences of 'Concept Set 1', a provider specialty that is: [none specified]; a visit occurrence that is: [none specified]."
));

}
}

0 comments on commit cebb8c5

Please sign in to comment.