Skip to content

Commit

Permalink
Fix startDateExpresion and endDateExpresison replacements.
Browse files Browse the repository at this point in the history
Fixes #170.
  • Loading branch information
chrisknoll committed Jul 19, 2022
1 parent 4504aa2 commit 9974480
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public String getCriteriaSql(T criteria, BuilderOptions options) {
String startDateExpression = (criteria.userDefinedPeriod != null && criteria.userDefinedPeriod.startDate != null)
? BuilderUtils.dateStringToSql(criteria.userDefinedPeriod.startDate)
: "C.payer_plan_period_start_date";
StringUtils.replace(query, "@startDateExpression", startDateExpression);
query = StringUtils.replace(query, "@startDateExpression", startDateExpression);

String endDateExpression = (criteria.userDefinedPeriod != null && criteria.userDefinedPeriod.endDate != null)
? BuilderUtils.dateStringToSql(criteria.userDefinedPeriod.endDate)
: "C.payer_plan_period_end_date";
StringUtils.replace(query, "@endDateExpression", endDateExpression);
query = StringUtils.replace(query, "@endDateExpression", endDateExpression);
return query;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,7 @@ public void allCriteriaTest() throws SQLException {
/* first occurrence tests */
private void setFirstOccurrenceCriteria(final Criteria c) throws Exception {
final Field first = c.getClass().getDeclaredField("first");
final Field codesetId = c.getClass().getDeclaredField("codesetId");
first.set(c, Boolean.valueOf(true));
codesetId.set(c, Integer.valueOf(0));
}

@Test
Expand Down Expand Up @@ -178,7 +176,8 @@ public void firstOccurrenceTest() throws Exception {
new Observation(),
new ProcedureOccurrence(),
new Specimen(),
new VisitOccurrence()
new VisitOccurrence(),
new PayerPlanPeriod()
};

// create and execute cohort for each test criteria
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,26 @@
"period_type_concept_id": 0
}
],
"cdm.payer_plan_period": [
{
"payer_plan_period_id": 1,
"person_id":1,
"payer_plan_period_start_date":"2000-07-05",
"payer_plan_period_end_date":"2000-07-12"
},
{
"payer_plan_period_id": 2,
"person_id":1,
"payer_plan_period_start_date":"2000-09-01",
"payer_plan_period_end_date":"2000-09-02"
},
{
"payer_plan_period_id": 3,
"person_id":2,
"payer_plan_period_start_date":"2000-01-01",
"payer_plan_period_end_date":"2000-01-02"
}
],
"cdm.procedure_occurrence": [
{
"procedure_occurrence_id": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
"subject_id":1,
"cohort_start_date":"2000-07-05",
"cohort_end_date":"2001-01-01"
}
},
{
"cohort_definition_id":11,
"subject_id":1,
"cohort_start_date":"2000-07-05",
"cohort_end_date":"2001-01-01"
}
]
}

0 comments on commit 9974480

Please sign in to comment.