Skip to content

Commit

Permalink
Added support for counting distinct target concepts to each additiona…
Browse files Browse the repository at this point in the history
…l filter item.

Added dependency to sqljdbc4 for POM. Only impacts mssql profile.
  • Loading branch information
chrisknoll committed Feb 27, 2015
1 parent 83022c8 commit c662573
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
.project
/nb-configuration.xml
/nbactions.xml
/nbactions-webapi-local.xml
/nbactions-webapi-local.xml
/nbactions-webapi-mssql.xml
19 changes: 19 additions & 0 deletions nb-licenseheader.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<#if licenseFirst??>
${licenseFirst}
</#if>
${licensePrefix}Copyright ${date?date?string("yyyy")} ${organization!user}.
${licensePrefix?replace(" +$", "", "r")}
${licensePrefix}Licensed under the Apache License, Version 2.0 (the "License");
${licensePrefix}you may not use this file except in compliance with the License.
${licensePrefix}You may obtain a copy of the License at
${licensePrefix?replace(" +$", "", "r")}
${licensePrefix} http://www.apache.org/licenses/LICENSE-2.0
${licensePrefix?replace(" +$", "", "r")}
${licensePrefix}Unless required by applicable law or agreed to in writing, software
${licensePrefix}distributed under the License is distributed on an "AS IS" BASIS,
${licensePrefix}WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
${licensePrefix}See the License for the specific language governing permissions and
${licensePrefix}limitations under the License.
<#if licenseLast??>
${licenseLast}
</#if>
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,14 @@
<flyway.datasource.password>FLYWAY_PASS</flyway.datasource.password>
<flyway.locations>classpath:db/migration/sqlserver</flyway.locations>
</properties>
<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
<type>jar</type>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private String getCodesetQuery(ConceptSet[] conceptSets) {
codesetQuery = StringUtils.replace(codesetQuery, "@codesetQueries", StringUtils.join(codesetQueries, "\nUNION\n"));
}
else {
codesetQuery = StringUtils.replace(codesetQuery, "@codesetQueries", "SELECT concept_id FROM @CDM_schema.CONCEPT where 0 = 1"); // by default, return an empty resultset
codesetQuery = StringUtils.replace(codesetQuery, "@codesetQueries", "SELECT -1 as codeset_id, concept_id FROM @CDM_schema.CONCEPT where 0 = 1"); // by default, return an empty resultset
}
return codesetQuery;
}
Expand Down Expand Up @@ -287,7 +287,8 @@ public String visit(AdditionalCriteria additionalCriteria)
query = StringUtils.replace(query,"@windowCriteria",windowCriteria);

String occurrenceCriteria = String.format(
"HAVING COUNT(A.PERSON_ID) %s %d",
"HAVING COUNT(%sA.TARGET_CONCEPT_ID) %s %d",
additionalCriteria.occurrence.isDistinct ? "DISTINCT " : "",
getOccurrenceOperator(additionalCriteria.occurrence.type),
additionalCriteria.occurrence.count
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ public class Occurrence {

@JsonProperty("Count")
public int count;

@JsonProperty("IsDistinct")
public boolean isDistinct;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select C.person_id, C.condition_era_start_date as start_date, C.condition_era_end_date as end_date
select C.person_id, C.condition_era_start_date as start_date, C.condition_era_end_date as end_date, C.CONDITION_CONCEPT_ID as TARGET_CONCEPT_ID
from
(
select ce.*, ROW_NUMBER() over (PARTITION BY ce.person_id ORDER BY ce.condition_era_start_date) as ordinal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select C.person_id, C.condition_start_date as start_date, C.condition_end_date as end_date
select C.person_id, C.condition_start_date as start_date, C.condition_end_date as end_date, C.CONDITION_CONCEPT_ID as TARGET_CONCEPT_ID
from
(
select co.*, ROW_NUMBER() over (PARTITION BY co.person_id ORDER BY co.condition_start_date) as ordinal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select C.person_id, C.death_date as start_date, DATEADD(d,1,C.death_date) as end_date
select C.person_id, C.death_date as start_date, DATEADD(d,1,C.death_date) as end_date, C.cause_concept_id as TARGET_CONCEPT_ID
from
(
select d.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select C.person_id, C.device_exposure_start_date as start_date, C.device_exposure_end_date as end_date
select C.person_id, C.device_exposure_start_date as start_date, C.device_exposure_end_date as end_date, C.device_concept_id as TARGET_CONCEPT_ID
from
(
select de.*, ROW_NUMBER() over (PARTITION BY de.person_id ORDER BY de.device_exposure_start_date) as ordinal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select C.person_id, C.dose_era_start_date as start_date, C.dose_era_end_date as end_date
select C.person_id, C.dose_era_start_date as start_date, C.dose_era_end_date as end_date, C.drug_concept_id as TARGET_CONCEPT_ID
from
(
select de.*, ROW_NUMBER() over (PARTITION BY de.person_id ORDER BY de.dose_era_start_date) as ordinal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select C.person_id, C.drug_era_start_date as start_date, C.drug_era_end_date as end_date
select C.person_id, C.drug_era_start_date as start_date, C.drug_era_end_date as end_date, C.drug_concept_id as TARGET_CONCEPT_ID
from
(
select de.*, ROW_NUMBER() over (PARTITION BY de.person_id ORDER BY de.drug_era_start_date) as ordinal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select C.person_id, C.drug_exposure_start_date as start_date, C.drug_exposure_end_date as end_date
select C.person_id, C.drug_exposure_start_date as start_date, C.drug_exposure_end_date as end_date, C.drug_concept_id as TARGET_CONCEPT_ID
from
(
select de.*, ROW_NUMBER() over (PARTITION BY de.person_id ORDER BY de.drug_exposure_start_date) as ordinal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select C.person_id, C.measurement_date as start_date, DATEADD(d,1,C.measurement_date) as END_DATE
select C.person_id, C.measurement_date as start_date, DATEADD(d,1,C.measurement_date) as END_DATE, C.measurement_concept_id as TARGET_CONCEPT_ID
from
(
select m.*, ROW_NUMBER() over (PARTITION BY m.person_id ORDER BY m.measurement_date) as ordinal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select C.person_id, C.observation_date as start_date, DATEADD(d,1,C.observation_date) as END_DATE
select C.person_id, C.observation_date as start_date, DATEADD(d,1,C.observation_date) as END_DATE, C.observation_concept_id as TARGET_CONCEPT_ID
from
(
select o.*, ROW_NUMBER() over (PARTITION BY o.person_id ORDER BY o.observation_date) as ordinal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select C.person_id, C.observation_period_start_date as start_date, C.observation_period_end_date as end_date
select C.person_id, C.observation_period_start_date as start_date, C.observation_period_end_date as end_date, C.period_type_concept_id as TARGET_CONCEPT_ID
from
(
select op.*, ROW_NUMBER() over (PARTITION BY op.person_id ORDER BY op.observation_period_start_date) as ordinal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select C.person_id, C.specimen_date as start_date, DATEADD(d,1,C.specimen_date) as end_date
select C.person_id, C.specimen_date as start_date, DATEADD(d,1,C.specimen_date) as end_date, C.specimen_concept_id as TARGET_CONCEPT_ID
from
(
select s.*, ROW_NUMBER() over (PARTITION BY s.person_id ORDER BY s.specimen_date) as ordinal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
select C.person_id, C.visit_start_date as start_date, C.visit_end_date as end_date
select C.person_id, C.visit_start_date as start_date, C.visit_end_date as end_date, C.visit_concept_id as TARGET_CONCEPT_ID
from
(
select vo.*, ROW_NUMBER() over (PARTITION BY vo.person_id ORDER BY vo.visit_start_date) as ordinal
Expand Down

0 comments on commit c662573

Please sign in to comment.