Skip to content

Commit 1f438df

Browse files
acumaravpavgra
authored andcommitted
Arachne-ui-issue-651. Fixes issues with reports import (#310)
1 parent a5b1a0c commit 1f438df

16 files changed

Lines changed: 316 additions & 247 deletions

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@
427427
<version>1.9.5</version>
428428
<configuration>
429429
<connectionType>developerConnection</connectionType>
430-
<scmVersion>v1.5.0</scmVersion>
431-
<scmVersionType>tag</scmVersionType>
430+
<scmVersion>cc1012f5fe7658860b66a7575a8906b6cf2ad064</scmVersion>
431+
<scmVersionType>revision</scmVersionType>
432432
<checkoutDirectory>src/achilles</checkoutDirectory>
433433
<skipCheckoutIfExists/>
434434
</configuration>
@@ -613,4 +613,4 @@
613613
</repository>
614614
</distributionManagement>
615615

616-
</project>
616+
</project>

src/main/java/com/odysseusinc/arachne/datanode/Constants.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ interface Achilles {
167167
String ACHILLES_RES_SCHEMA = "ACHILLES_RES_SCHEMA";
168168
String ACHILLES_CDM_VERSION = "ACHILLES_CDM_VERSION";
169169
String DEFAULT_CDM_VERSION = "5";
170+
String ACHILLES_NUM_THREADS = "ACHILLES_NUM_THREADS";
170171
}
171172

172173
interface Atlas {
@@ -178,4 +179,23 @@ interface Atlas {
178179

179180
ComparableVersion ATLAS_2_7_VERSION = new ComparableVersion("2.7.0");
180181
}
182+
183+
interface CDM {
184+
String category = "category";
185+
String concept_id = "concept_id";
186+
String CONCEPT_ID = "CONCEPT_ID";
187+
String concept_name = "concept_name";
188+
String count_value = "count_value";
189+
String DRUG_CONCEPT_ID = "DRUG_CONCEPT_ID";
190+
String max_value = "max_value";
191+
String measurement_concept_id = "measurement_concept_id";
192+
String MEASUREMENT_CONCEPT_ID = "MEASUREMENT_CONCEPT_ID";
193+
String median_value = "median_value";
194+
String min_value = "min_value";
195+
String p10_value = "p10_value";
196+
String p25_value = "p25_value";
197+
String p75_value = "p75_value";
198+
String p90_value = "p90_value";
199+
}
200+
181201
}

src/main/java/com/odysseusinc/arachne/datanode/service/achilles/AchillesProcessors.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ public class AchillesProcessors {
4343

4444
private static final Logger LOGGER = LoggerFactory.getLogger(AchillesProcessors.class);
4545

46+
private AchillesProcessors(){
47+
}
48+
4649
public static ResultSetProcessor<Map> achillesHeel() {
4750

4851
return resultSet -> {
4952
Map<String, Object> data = new HashMap<>();
50-
data.put("MESSAGES", resultSet().process(resultSet));
53+
ResultSetContainer<Map> resultContainer = resultSet().process(resultSet);
54+
data.put("MESSAGES", resultContainer.getValues());
5155
return new ResultSetContainer<>(data, null);
5256
};
5357
}
@@ -100,7 +104,7 @@ public static ResultSetProcessor<Map> statsDataResultSet() {
100104

101105
return resultSet -> {
102106
Map<String, Object> data = new HashMap<>();
103-
data.put("DATA", resultSet().process(resultSet));
107+
data.put("DATA", resultSet().process(resultSet).getValues());
104108
return new ResultSetContainer<>(data, null);
105109
};
106110
}
@@ -146,7 +150,7 @@ public static <K> ResultSetProcessor<Map> plainResultSet(String primaryKey, Stri
146150
Map values = columns.entrySet().stream()
147151
.filter(e -> !Objects.equals(e.getKey(), primaryKey))
148152
.collect(Collectors.toMap(
149-
e -> e.getKey(),
153+
Map.Entry::getKey,
150154
e -> {
151155
try {
152156
return getColumnValue(resultSet, e.getKey(), e.getValue());

src/main/java/com/odysseusinc/arachne/datanode/service/achilles/ConditionEraReport.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
package com.odysseusinc.arachne.datanode.service.achilles;
2424

25+
import static com.odysseusinc.arachne.datanode.Constants.CDM.CONCEPT_ID;
26+
import static com.odysseusinc.arachne.datanode.Constants.CDM.concept_id;
2527
import static com.odysseusinc.arachne.datanode.service.achilles.AchillesProcessors.plainResultSet;
2628

2729
import com.odysseusinc.arachne.datanode.model.datasource.DataSource;
@@ -41,10 +43,10 @@
4143
@Component
4244
public class ConditionEraReport extends BaseReport {
4345

44-
public static final String CONDITIONERA_PREVALENCE_BY_GENDER_AGE_YEAR_SQL = "classpath:/achilles/data/export_v5/conditionera/sqlPrevalenceByGenderAgeYear.sql";
45-
public static final String CONDITIONERA_LENGTH_OF_ERA = "classpath:/achilles/data/export_v5/conditionera/sqlLengthOfEra.sql";
46-
public static final String CONDITIONERA_PREVALENCE_BY_MONTH_SQL = "classpath:/achilles/data/export_v5/conditionera/sqlPrevalenceByMonth.sql";
47-
public static final String CONDITIONERA_AGE_AT_FIRST_DIAGNOSIS_SQL = "classpath:/achilles/data/export_v5/conditionera/sqlAgeAtFirstDiagnosis.sql";
46+
public static final String CONDITIONERA_PREVALENCE_BY_GENDER_AGE_YEAR_SQL = "classpath:/achilles/data/export/conditionera/sqlPrevalenceByGenderAgeYear.sql";
47+
public static final String CONDITIONERA_LENGTH_OF_ERA = "classpath:/achilles/data/export/conditionera/sqlLengthOfEra.sql";
48+
public static final String CONDITIONERA_PREVALENCE_BY_MONTH_SQL = "classpath:/achilles/data/export/conditionera/sqlPrevalenceByMonth.sql";
49+
public static final String CONDITIONERA_AGE_AT_FIRST_DIAGNOSIS_SQL = "classpath:/achilles/data/export/conditionera/sqlAgeAtFirstDiagnosis.sql";
4850

4951
@Autowired
5052
public ConditionEraReport(SqlUtils sqlUtils) {
@@ -61,18 +63,18 @@ protected Integer execReport(DataSource dataSource, Path targetDir, List<Integer
6163
String lengthQuery = sqlUtils.transformSqlTemplate(dataSource, CONDITIONERA_LENGTH_OF_ERA);
6264
return DataSourceUtils.<Map<Integer, String>>withDataSource(dataSource)
6365
.run(QueryProcessors.statement(prevalenceByGenderAgeQuery))
64-
.forMapResults(concepts, "CONCEPT_ID", "PREVALENCE_BY_GENDER_AGE_YEAR",
65-
plainResultSet("concept_id", "trellis_name", "series_name", "x_calendar_year", "y_prevalence_1000pp"))
66+
.forMapResults(concepts, CONCEPT_ID, "PREVALENCE_BY_GENDER_AGE_YEAR",
67+
plainResultSet(concept_id, "trellis_name", "series_name", "x_calendar_year", "y_prevalence_1000pp"))
6668
.run(QueryProcessors.statement(prevalenceByMonthQuery))
67-
.forMapResults(concepts, "CONCEPT_ID", "PREVALENCE_BY_MONTH",
68-
plainResultSet("concept_id", "x_calendar_month", "y_prevalence_1000pp"))
69+
.forMapResults(concepts, CONCEPT_ID, "PREVALENCE_BY_MONTH",
70+
plainResultSet(concept_id, "x_calendar_month", "y_prevalence_1000pp"))
6971
.run(QueryProcessors.statement(ageQuery))
70-
.forMapResults(concepts, "CONCEPT_ID", "AGE_AT_FIRST_DIAGNOSIS",
71-
plainResultSet("concept_id", "category", "min_value", "p10_value",
72+
.forMapResults(concepts, CONCEPT_ID, "AGE_AT_FIRST_DIAGNOSIS",
73+
plainResultSet(concept_id, "category", "min_value", "p10_value",
7274
"p25_value", "median_value", "p75_value", "p90_value", "max_value"))
7375
.run(QueryProcessors.statement(lengthQuery))
74-
.forMapResults(concepts, "CONCEPT_ID", "LENGTH_OF_ERA",
75-
plainResultSet("concept_id", "category", "min_value", "p10_value",
76+
.forMapResults(concepts, CONCEPT_ID, "LENGTH_OF_ERA",
77+
plainResultSet(concept_id, "category", "min_value", "p10_value",
7678
"p25_value", "median_value", "p75_value", "p90_value", "max_value"))
7779
.transform(ResultTransformers.toJsonMap(concepts))
7880
.write(ResultWriters.toMultipleFiles(targetDir, "condition_%d.json", concepts))

src/main/java/com/odysseusinc/arachne/datanode/service/achilles/ConditionReport.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
package com.odysseusinc.arachne.datanode.service.achilles;
2424

25+
import static com.odysseusinc.arachne.datanode.Constants.CDM.CONCEPT_ID;
26+
import static com.odysseusinc.arachne.datanode.Constants.CDM.concept_id;
2527
import static com.odysseusinc.arachne.datanode.service.achilles.AchillesProcessors.plainResultSet;
2628

2729
import com.odysseusinc.arachne.datanode.model.datasource.DataSource;
@@ -41,10 +43,10 @@
4143
@Component
4244
public class ConditionReport extends BaseReport {
4345

44-
public static final String CONDITION_PREVALENCE_BY_GENDER_AGE_YEAR_SQL = "classpath:/achilles/data/export_v5/condition/sqlPrevalenceByGenderAgeYear.sql";
45-
public static final String CONDITION_PREVALENCE_BY_MONTH_SQL = "classpath:/achilles/data/export_v5/condition/sqlPrevalenceByMonth.sql";
46-
public static final String CONDITION_CONDITIONS_BY_TYPE_SQL = "classpath:/achilles/data/export_v5/condition/sqlConditionsByType.sql";
47-
public static final String CONDITION_AGE_AT_FIRST_DIAGNOSIS_SQL = "classpath:/achilles/data/export_v5/condition/sqlAgeAtFirstDiagnosis.sql";
46+
public static final String CONDITION_PREVALENCE_BY_GENDER_AGE_YEAR_SQL = "classpath:/achilles/data/export/condition/sqlPrevalenceByGenderAgeYear.sql";
47+
public static final String CONDITION_PREVALENCE_BY_MONTH_SQL = "classpath:/achilles/data/export/condition/sqlPrevalenceByMonth.sql";
48+
public static final String CONDITION_CONDITIONS_BY_TYPE_SQL = "classpath:/achilles/data/export/condition/sqlConditionsByType.sql";
49+
public static final String CONDITION_AGE_AT_FIRST_DIAGNOSIS_SQL = "classpath:/achilles/data/export/condition/sqlAgeAtFirstDiagnosis.sql";
4850

4951
@Autowired
5052
public ConditionReport(SqlUtils sqlUtils) {
@@ -61,17 +63,17 @@ protected Integer execReport(DataSource dataSource, Path targetDir, List<Integer
6163
String ageQuery = sqlUtils.transformSqlTemplate(dataSource, CONDITION_AGE_AT_FIRST_DIAGNOSIS_SQL);
6264
return DataSourceUtils.<Map<Integer, String>>withDataSource(dataSource)
6365
.run(QueryProcessors.statement(prevalenceByGenderAgeQuery))
64-
.forMapResults(concepts, "CONCEPT_ID", "PREVALENCE_BY_GENDER_AGE_YEAR",
65-
plainResultSet("concept_id", "trellis_name", "series_name", "x_calendar_year", "y_prevalence_1000pp"))
66+
.forMapResults(concepts, CONCEPT_ID, "PREVALENCE_BY_GENDER_AGE_YEAR",
67+
plainResultSet(concept_id, "trellis_name", "series_name", "x_calendar_year", "y_prevalence_1000pp"))
6668
.run(QueryProcessors.statement(prevalenceByMonthQuery))
67-
.forMapResults(concepts, "CONCEPT_ID", "PREVALENCE_BY_MONTH",
68-
plainResultSet("concept_id", "x_calendar_month", "y_prevalence_1000pp"))
69+
.forMapResults(concepts, CONCEPT_ID, "PREVALENCE_BY_MONTH",
70+
plainResultSet(concept_id, "x_calendar_month", "y_prevalence_1000pp"))
6971
.run(QueryProcessors.statement(conditionByTypeQuery))
7072
.forMapResults(concepts, "CONDITION_CONCEPT_ID", "CONDITIONS_BY_TYPE",
7173
plainResultSet("condition_concept_id", "concept_name", "count_value"))
7274
.run(QueryProcessors.statement(ageQuery))
73-
.forMapResults(concepts, "CONCEPT_ID", "AGE_AT_FIRST_DIAGNOSIS",
74-
plainResultSet("concept_id", "category", "min_value", "p10_value",
75+
.forMapResults(concepts, CONCEPT_ID, "AGE_AT_FIRST_DIAGNOSIS",
76+
plainResultSet(concept_id, "category", "min_value", "p10_value",
7577
"p25_value", "median_value", "p75_value", "p90_value", "max_value"))
7678
.transform(ResultTransformers.toJsonMap(concepts))
7779
.write(ResultWriters.toMultipleFiles(targetDir, "condition_%d.json", concepts))

src/main/java/com/odysseusinc/arachne/datanode/service/achilles/DataDensityReport.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
@Component
4040
public class DataDensityReport extends BaseReport {
4141

42-
public static final String DATADENSITY_TOTALRECORDS_SQL = "classpath:/achilles/data/export_v5/datadensity/totalrecords.sql";
43-
public static final String DATADENSITY_RECORDSPERPERSON_SQL = "classpath:/achilles/data/export_v5/datadensity/recordsperperson.sql";
44-
public static final String DATADENSITY_CONCEPTSPERPERSON_SQL = "classpath:/achilles/data/export_v5/datadensity/conceptsperperson.sql";
42+
public static final String DATADENSITY_TOTALRECORDS_SQL = "classpath:/achilles/data/export/datadensity/totalrecords.sql";
43+
public static final String DATADENSITY_RECORDSPERPERSON_SQL = "classpath:/achilles/data/export/datadensity/recordsperperson.sql";
44+
public static final String DATADENSITY_CONCEPTSPERPERSON_SQL = "classpath:/achilles/data/export/datadensity/conceptsperperson.sql";
4545

4646
public DataDensityReport(SqlUtils sqlUtils) {
4747

src/main/java/com/odysseusinc/arachne/datanode/service/achilles/DeathReport.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
@Component
4040
public class DeathReport extends BaseReport {
4141

42-
public static final String DEATH_AGE_AT_FIRST_EXPOSURE_SQL = "classpath:/achilles/data/export_v5/death/sqlAgeAtDeath.sql";
43-
public static final String DEATH_DRUGS_BY_TYPE_SQL = "classpath:/achilles/data/export_v5/death/sqlDeathByType.sql";
44-
public static final String DEATH_PREVALENCE_BY_GENDER_AGE_YEAR_SQL = "classpath:/achilles/data/export_v5/death/sqlPrevalenceByGenderAgeYear.sql";
45-
public static final String DEATH_PREVALENCE_BY_MONTH_SQL = "classpath:/achilles/data/export_v5/death/sqlPrevalenceByMonth.sql";
42+
public static final String DEATH_AGE_AT_FIRST_EXPOSURE_SQL = "classpath:/achilles/data/export/death/sqlAgeAtDeath.sql";
43+
public static final String DEATH_DRUGS_BY_TYPE_SQL = "classpath:/achilles/data/export/death/sqlDeathByType.sql";
44+
public static final String DEATH_PREVALENCE_BY_GENDER_AGE_YEAR_SQL = "classpath:/achilles/data/export/death/sqlPrevalenceByGenderAgeYear.sql";
45+
public static final String DEATH_PREVALENCE_BY_MONTH_SQL = "classpath:/achilles/data/export/death/sqlPrevalenceByMonth.sql";
4646

4747
public DeathReport(SqlUtils sqlUtils) {
4848

src/main/java/com/odysseusinc/arachne/datanode/service/achilles/DrugEraReport.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
package com.odysseusinc.arachne.datanode.service.achilles;
2424

25+
import static com.odysseusinc.arachne.datanode.Constants.CDM.CONCEPT_ID;
26+
import static com.odysseusinc.arachne.datanode.Constants.CDM.concept_id;
27+
2528
import com.odysseusinc.arachne.datanode.model.datasource.DataSource;
2629
import com.odysseusinc.arachne.datanode.util.DataSourceUtils;
2730
import com.odysseusinc.arachne.datanode.util.SqlUtils;
@@ -38,10 +41,10 @@
3841

3942
@Component
4043
public class DrugEraReport extends BaseReport {
41-
public static final String DRUGERA_AGE_AT_FIRST_EXPOSURE_SQL = "classpath:/achilles/data/export_v5/drugera/sqlAgeAtFirstExposure.sql";
42-
public static final String DRUGERA_PREVALENCE_BY_GENDER_AGE_YEAR_SQL = "classpath:/achilles/data/export_v5/drugera/sqlPrevalenceByGenderAgeYear.sql";
43-
public static final String DRUGERA_PREVALENCE_BY_MONTH_SQL = "classpath:/achilles/data/export_v5/drugera/sqlPrevalenceByMonth.sql";
44-
public static final String DRUGERA_LENGTH_OF_ERA_SQL = "classpath:/achilles/data/export_v5/drugera/sqlLengthOfEra.sql";
44+
public static final String DRUGERA_AGE_AT_FIRST_EXPOSURE_SQL = "classpath:/achilles/data/export/drugera/sqlAgeAtFirstExposure.sql";
45+
public static final String DRUGERA_PREVALENCE_BY_GENDER_AGE_YEAR_SQL = "classpath:/achilles/data/export/drugera/sqlPrevalenceByGenderAgeYear.sql";
46+
public static final String DRUGERA_PREVALENCE_BY_MONTH_SQL = "classpath:/achilles/data/export/drugera/sqlPrevalenceByMonth.sql";
47+
public static final String DRUGERA_LENGTH_OF_ERA_SQL = "classpath:/achilles/data/export/drugera/sqlLengthOfEra.sql";
4548

4649
@Autowired
4750
public DrugEraReport(SqlUtils sqlUtils) {
@@ -58,17 +61,17 @@ protected Integer execReport(DataSource dataSource, Path targetDir, List<Integer
5861
String lengthQuery = sqlUtils.transformSqlTemplate(dataSource, DRUGERA_LENGTH_OF_ERA_SQL);
5962
return DataSourceUtils.<Map<Integer, String>>withDataSource(dataSource)
6063
.run(QueryProcessors.statement(ageExposureQuery))
61-
.forMapResults(concepts, "CONCEPT_ID", "AGE_AT_FIRST_EXPOSURE",
62-
AchillesProcessors.plainResultSet("concept_id", "category", "min_value", "p10_value", "p25_value", "median_value", "p75_value", "p90_value", "max_value"))
64+
.forMapResults(concepts, CONCEPT_ID, "AGE_AT_FIRST_EXPOSURE",
65+
AchillesProcessors.plainResultSet(concept_id, "category", "min_value", "p10_value", "p25_value", "median_value", "p75_value", "p90_value", "max_value"))
6366
.run(QueryProcessors.statement(prevalenceByGenderQuery))
64-
.forMapResults(concepts, "CONCEPT_ID", "PREVALENCE_BY_GENDER_AGE_YEAR",
65-
AchillesProcessors.plainResultSet("concept_id", "trellis_name", "series_name", "x_calendar_year", "y_prevalence_1000pp"))
67+
.forMapResults(concepts, CONCEPT_ID, "PREVALENCE_BY_GENDER_AGE_YEAR",
68+
AchillesProcessors.plainResultSet(concept_id, "trellis_name", "series_name", "x_calendar_year", "y_prevalence_1000pp"))
6669
.run(QueryProcessors.statement(prevalenceByMonth))
67-
.forMapResults(concepts, "CONCEPT_ID", "PREVALENCE_BY_MONTH",
68-
AchillesProcessors.plainResultSet("concept_id", "x_calendar_month", "y_prevalence_1000pp"))
70+
.forMapResults(concepts, CONCEPT_ID, "PREVALENCE_BY_MONTH",
71+
AchillesProcessors.plainResultSet(concept_id, "x_calendar_month", "y_prevalence_1000pp"))
6972
.run(QueryProcessors.statement(lengthQuery))
70-
.forMapResults(concepts, "CONCEPT_ID", "LENGTH_OF_ERA",
71-
AchillesProcessors.plainResultSet("concept_id", "category", "min_value", "p10_value", "p25_value", "median_value", "p75_value", "p90_value", "max_value"))
73+
.forMapResults(concepts, CONCEPT_ID, "LENGTH_OF_ERA",
74+
AchillesProcessors.plainResultSet(concept_id, "category", "min_value", "p10_value", "p25_value", "median_value", "p75_value", "p90_value", "max_value"))
7275
.transform(ResultTransformers.toJsonMap(concepts))
7376
.write(ResultWriters.toMultipleFiles(targetDir, "drug_%d.json", concepts))
7477
.getResultsCount();

0 commit comments

Comments
 (0)