From ac5de23a63ad658373146ea07b9645db7c169526 Mon Sep 17 00:00:00 2001 From: Taha Abdul-Basser Date: Thu, 12 May 2016 16:22:42 -0400 Subject: [PATCH 1/2] ignore IntelliJ files add'l characterization/summarization work added SQL files for summary service from Achilles::ExportToJSON added data transfer objects (DTOs) modified CDMResultsService, made several sql translation changes, moved mappers and DTOs to report package in preparation for refactoring. added add'l DTOs to report package and stubbed out service and runner classes. fixed imports fixed imports in some DTOs and RowMappers --- .gitignore | 2 + .idea/compiler.xml | 32 + .../org/ohdsi/webapi/DataAccessConfig.java | 152 +-- .../cohortresults/VisualizationData.java | 254 ++--- .../ohdsi/webapi/report/CDMAchillesHeel.java | 7 + .../org/ohdsi/webapi/report/CDMCondition.java | 7 + .../ohdsi/webapi/report/CDMConditionEra.java | 7 + .../org/ohdsi/webapi/report/CDMDashboard.java | 63 ++ .../ohdsi/webapi/report/CDMDataDensity.java | 7 + .../ohdsi/webapi/report/CDMDrugSummary.java | 7 + .../ohdsi/webapi/report/CDMObservation.java | 7 + .../webapi/report/CDMObservationPeriod.java | 7 + .../ohdsi/webapi/report/CDMPersonSummary.java | 79 ++ .../webapi/report/CDMProcedureSummary.java | 7 + .../ohdsi/webapi/report/CohortAttribute.java | 33 + .../ohdsi/webapi/report/CohortBreakdown.java | 18 + .../report/CohortConditionDrilldown.java | 70 ++ .../report/CohortConditionEraDrilldown.java | 62 ++ .../webapi/report/CohortDataDensity.java | 47 + .../ohdsi/webapi/report/CohortDeathData.java | 72 ++ .../webapi/report/CohortDrugDrilldown.java | 103 ++ .../webapi/report/CohortDrugEraDrilldown.java | 61 ++ .../report/CohortMeasurementDrilldown.java | 133 +++ .../report/CohortObservationDrilldown.java | 133 +++ .../report/CohortObservationPeriod.java | 162 ++++ .../webapi/report/CohortPersonSummary.java | 76 ++ .../report/CohortProceduresDrillDown.java | 71 ++ .../webapi/report/CohortSpecificSummary.java | 119 +++ .../webapi/report/CohortSpecificTreemap.java | 51 + .../webapi/report/CohortStatsRecord.java | 45 + .../webapi/report/CohortVisitsDrilldown.java | 71 ++ .../webapi/report/ConceptCountRecord.java | 105 ++ .../webapi/report/ConceptDecileRecord.java | 91 ++ .../report/ConceptDistributionRecord.java | 50 + .../webapi/report/ConceptQuartileRecord.java | 131 +++ .../report/CumulativeObservationRecord.java | 45 + .../webapi/report/ExposureCohortResult.java | 35 + .../webapi/report/ExposureCohortSearch.java | 26 + .../report/HierarchicalConceptRecord.java | 167 ++++ .../webapi/report/MonthObservationRecord.java | 45 + .../report/ObservationPeriodRecord.java | 58 ++ .../ohdsi/webapi/report/PredictorResult.java | 41 + .../ohdsi/webapi/report/PrevalenceRecord.java | 72 ++ .../webapi/report/ScatterplotRecord.java | 84 ++ .../ohdsi/webapi/report/SeriesPerPerson.java | 43 + .../webapi/report/TimeToEventResult.java | 32 + .../report/mapper/CohortAttributeMapper.java | 19 + .../report/mapper/CohortStatsMapper.java | 21 + .../mapper/ConceptConditionCountMapper.java | 23 + .../report/mapper/ConceptCountMapper.java | 20 + .../mapper/ConceptDecileCountsMapper.java | 22 + .../report/mapper/ConceptDecileMapper.java | 22 + .../mapper/ConceptDistributionMapper.java | 21 + .../mapper/ConceptObservationCountMapper.java | 23 + .../report/mapper/ConceptQuartileMapper.java | 26 + .../mapper/CumulativeObservationMapper.java | 20 + .../mapper/HierarchicalConceptEraMapper.java | 22 + .../mapper/HierarchicalConceptMapper.java | 22 + .../HierarchicalConceptPrevalenceMapper.java | 26 + .../report/mapper/MonthObservationMapper.java | 20 + .../mapper/ObservationPeriodMapper.java | 22 + .../mapper/PrevalanceConceptMapper.java | 21 + .../mapper/PrevalanceConceptNameMapper.java | 22 + .../report/mapper/PrevalanceMapper.java | 21 + .../report/mapper/ScatterplotMapper.java | 24 + .../report/mapper/SeriesPerPersonMapper.java | 21 + .../org/ohdsi/webapi/report/package-info.java | 4 + .../webapi/service/CDMResultsService.java | 894 ++++++++++++++---- .../report/achillesheel/sqlAchillesHeel.sql | 3 + .../condition/sqlAgeAtFirstDiagnosis.sql | 17 + .../report/condition/sqlConditionTreemap.sql | 98 ++ .../report/condition/sqlConditionsByType.sql | 38 + .../sqlPrevalenceByGenderAgeYear.sql | 35 + .../report/condition/sqlPrevalenceByMonth.sql | 13 + .../conditionera/sqlAgeAtFirstDiagnosis.sql | 16 + .../conditionera/sqlConditionEraTreemap.sql | 101 ++ .../report/conditionera/sqlLengthOfEra.sql | 14 + .../sqlPrevalenceByGenderAgeYear.sql | 34 + .../conditionera/sqlPrevalenceByMonth.sql | 10 + .../report/datadensity/conceptsperperson.sql | 76 ++ .../report/datadensity/recordsperperson.sql | 27 + .../sql/report/datadensity/totalrecords.sql | 24 + .../sql/report/death/sqlAgeAtDeath.sql | 12 + .../sql/report/death/sqlDeathByType.sql | 6 + .../death/sqlPrevalenceByGenderAgeYear.sql | 13 + .../sql/report/death/sqlPrevalenceByMonth.sql | 7 + .../sql/report/drug/sqlAgeAtFirstExposure.sql | 18 + .../report/drug/sqlDaysSupplyDistribution.sql | 15 + .../sql/report/drug/sqlDrugTreemap.sql | 98 ++ .../sql/report/drug/sqlDrugsByType.sql | 12 + .../drug/sqlPrevalenceByGenderAgeYear.sql | 33 + .../sql/report/drug/sqlPrevalenceByMonth.sql | 12 + .../report/drug/sqlQuantityDistribution.sql | 15 + .../report/drug/sqlRefillsDistribution.sql | 15 + .../report/drugera/sqlAgeAtFirstExposure.sql | 18 + .../sql/report/drugera/sqlDrugEraTreemap.sql | 89 ++ .../sql/report/drugera/sqlLengthOfEra.sql | 15 + .../drugera/sqlPrevalenceByGenderAgeYear.sql | 33 + .../report/drugera/sqlPrevalenceByMonth.sql | 11 + .../measurement/sqlAgeAtFirstOccurrence.sql | 13 + .../measurement/sqlLowerLimitDistribution.sql | 14 + .../measurement/sqlMeasurementTreemap.sql | 30 + .../sqlMeasurementValueDistribution.sql | 15 + .../measurement/sqlMeasurementsByType.sql | 9 + .../sqlPrevalenceByGenderAgeYear.sql | 34 + .../measurement/sqlPrevalenceByMonth.sql | 10 + .../report/measurement/sqlRecordsByUnit.sql | 9 + .../measurement/sqlUpperLimitDistribution.sql | 14 + .../measurement/sqlValuesRelativeToNorm.sql | 9 + .../observation/sqlAgeAtFirstOccurrence.sql | 13 + .../observation/sqlObservationTreemap.sql | 30 + .../observation/sqlObservationsByType.sql | 9 + .../sqlPrevalenceByGenderAgeYear.sql | 34 + .../observation/sqlPrevalenceByMonth.sql | 10 + .../report/observationperiod/ageatfirst.sql | 10 + .../report/observationperiod/agebygender.sql | 11 + .../observationperiod/cumulativeduration.sql | 13 + .../observationlength_data.sql | 9 + .../observationlength_stats.sql | 9 + .../observationlengthbyage.sql | 10 + .../observationlengthbygender.sql | 11 + .../observationperiod/observedbymonth.sql | 7 + .../observationperiod/observedbyyear_data.sql | 14 + .../observedbyyear_stats.sql | 5 + .../observationperiod/periodsperperson.sql | 5 + .../sql/report/person/ethnicity.sql | 8 + .../cdmresults/sql/report/person/gender.sql | 9 + .../sql/report/person/population.sql | 19 + .../cdmresults/sql/report/person/race.sql | 8 + .../sql/report/person/yearofbirth_data.sql | 7 + .../sql/report/person/yearofbirth_stats.sql | 5 + .../procedure/sqlAgeAtFirstOccurrence.sql | 17 + .../sqlPrevalenceByGenderAgeYear.sql | 33 + .../report/procedure/sqlPrevalenceByMonth.sql | 11 + .../report/procedure/sqlProcedureTreemap.sql | 117 +++ .../report/procedure/sqlProceduresByType.sql | 9 + .../report/visit/sqlAgeAtFirstOccurrence.sql | 13 + .../visit/sqlPrevalenceByGenderAgeYear.sql | 35 + .../sql/report/visit/sqlPrevalenceByMonth.sql | 10 + .../report/visit/sqlVisitDurationByType.sql | 13 + .../sql/report/visit/sqlVisitTreemap.sql | 11 + .../observationperiod/sql/ageatfirst.sql | 10 + .../observationperiod/sql/agebygender.sql | 11 + .../sql/cumulativeduration.sql | 13 + .../sql/observationlength_data.sql | 9 + .../sql/observationlength_stats.sql | 9 + .../sql/observationlengthbyage.sql | 10 + .../sql/observationlengthbygender.sql | 11 + .../observationperiod/sql/observedbymonth.sql | 7 + .../sql/observedbyyear_data.sql | 14 + .../sql/observedbyyear_stats.sql | 5 + .../sql/periodsperperson.sql | 5 + .../resources/person/sql/ethnicity.sql | 9 + .../resources/resources/person/sql/gender.sql | 9 + .../resources/person/sql/population.sql | 19 + .../resources/resources/person/sql/race.sql | 8 + .../resources/person/sql/yearofbirth_data.sql | 7 + .../person/sql/yearofbirth_stats.sql | 5 + .../test/CharacterizationServiceIT.java | 60 ++ .../resources/application-test.properties | 10 +- 160 files changed, 5797 insertions(+), 370 deletions(-) create mode 100644 .idea/compiler.xml create mode 100644 src/main/java/org/ohdsi/webapi/report/CDMAchillesHeel.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CDMCondition.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CDMConditionEra.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CDMDashboard.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CDMDataDensity.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CDMDrugSummary.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CDMObservation.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CDMObservationPeriod.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CDMPersonSummary.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CDMProcedureSummary.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortAttribute.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortBreakdown.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortConditionDrilldown.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortConditionEraDrilldown.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortDataDensity.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortDeathData.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortDrugDrilldown.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortDrugEraDrilldown.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortMeasurementDrilldown.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortObservationDrilldown.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortObservationPeriod.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortPersonSummary.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortProceduresDrillDown.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortSpecificSummary.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortSpecificTreemap.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortStatsRecord.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CohortVisitsDrilldown.java create mode 100644 src/main/java/org/ohdsi/webapi/report/ConceptCountRecord.java create mode 100644 src/main/java/org/ohdsi/webapi/report/ConceptDecileRecord.java create mode 100644 src/main/java/org/ohdsi/webapi/report/ConceptDistributionRecord.java create mode 100644 src/main/java/org/ohdsi/webapi/report/ConceptQuartileRecord.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CumulativeObservationRecord.java create mode 100644 src/main/java/org/ohdsi/webapi/report/ExposureCohortResult.java create mode 100644 src/main/java/org/ohdsi/webapi/report/ExposureCohortSearch.java create mode 100644 src/main/java/org/ohdsi/webapi/report/HierarchicalConceptRecord.java create mode 100644 src/main/java/org/ohdsi/webapi/report/MonthObservationRecord.java create mode 100644 src/main/java/org/ohdsi/webapi/report/ObservationPeriodRecord.java create mode 100644 src/main/java/org/ohdsi/webapi/report/PredictorResult.java create mode 100644 src/main/java/org/ohdsi/webapi/report/PrevalenceRecord.java create mode 100644 src/main/java/org/ohdsi/webapi/report/ScatterplotRecord.java create mode 100644 src/main/java/org/ohdsi/webapi/report/SeriesPerPerson.java create mode 100644 src/main/java/org/ohdsi/webapi/report/TimeToEventResult.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/CohortAttributeMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/CohortStatsMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/ConceptConditionCountMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/ConceptCountMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileCountsMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/ConceptDistributionMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/ConceptObservationCountMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/ConceptQuartileMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/CumulativeObservationMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/HierarchicalConceptEraMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/HierarchicalConceptMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/HierarchicalConceptPrevalenceMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/MonthObservationMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/ObservationPeriodMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceConceptMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceConceptNameMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/ScatterplotMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/SeriesPerPersonMapper.java create mode 100644 src/main/java/org/ohdsi/webapi/report/package-info.java create mode 100644 src/main/resources/resources/cdmresults/sql/report/achillesheel/sqlAchillesHeel.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/condition/sqlAgeAtFirstDiagnosis.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/condition/sqlConditionTreemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/condition/sqlConditionsByType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/condition/sqlPrevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/condition/sqlPrevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/conditionera/sqlAgeAtFirstDiagnosis.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/conditionera/sqlConditionEraTreemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/conditionera/sqlLengthOfEra.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/conditionera/sqlPrevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/conditionera/sqlPrevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/datadensity/conceptsperperson.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/datadensity/recordsperperson.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/datadensity/totalrecords.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/death/sqlAgeAtDeath.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/death/sqlDeathByType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/sqlAgeAtFirstExposure.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/sqlDaysSupplyDistribution.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/sqlDrugTreemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/sqlDrugsByType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/sqlPrevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/sqlPrevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/sqlQuantityDistribution.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/sqlRefillsDistribution.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drugera/sqlAgeAtFirstExposure.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drugera/sqlDrugEraTreemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drugera/sqlLengthOfEra.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drugera/sqlPrevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drugera/sqlPrevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/sqlAgeAtFirstOccurrence.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/sqlLowerLimitDistribution.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementTreemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementValueDistribution.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementsByType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/sqlPrevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/sqlPrevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/sqlRecordsByUnit.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/sqlUpperLimitDistribution.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/sqlValuesRelativeToNorm.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observation/sqlAgeAtFirstOccurrence.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observation/sqlObservationTreemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observation/sqlObservationsByType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observation/sqlPrevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observation/sqlPrevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observationperiod/ageatfirst.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observationperiod/agebygender.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observationperiod/cumulativeduration.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_data.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_stats.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbyage.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbygender.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbymonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_data.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_stats.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observationperiod/periodsperperson.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/person/ethnicity.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/person/gender.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/person/population.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/person/race.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_data.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_stats.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/procedure/sqlAgeAtFirstOccurrence.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/procedure/sqlPrevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/procedure/sqlPrevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/procedure/sqlProcedureTreemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/procedure/sqlProceduresByType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/visit/sqlAgeAtFirstOccurrence.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/visit/sqlPrevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/visit/sqlPrevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/visit/sqlVisitDurationByType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/visit/sqlVisitTreemap.sql create mode 100644 src/main/resources/resources/observationperiod/sql/ageatfirst.sql create mode 100644 src/main/resources/resources/observationperiod/sql/agebygender.sql create mode 100644 src/main/resources/resources/observationperiod/sql/cumulativeduration.sql create mode 100644 src/main/resources/resources/observationperiod/sql/observationlength_data.sql create mode 100644 src/main/resources/resources/observationperiod/sql/observationlength_stats.sql create mode 100644 src/main/resources/resources/observationperiod/sql/observationlengthbyage.sql create mode 100644 src/main/resources/resources/observationperiod/sql/observationlengthbygender.sql create mode 100644 src/main/resources/resources/observationperiod/sql/observedbymonth.sql create mode 100644 src/main/resources/resources/observationperiod/sql/observedbyyear_data.sql create mode 100644 src/main/resources/resources/observationperiod/sql/observedbyyear_stats.sql create mode 100644 src/main/resources/resources/observationperiod/sql/periodsperperson.sql create mode 100644 src/main/resources/resources/person/sql/ethnicity.sql create mode 100644 src/main/resources/resources/person/sql/gender.sql create mode 100644 src/main/resources/resources/person/sql/population.sql create mode 100644 src/main/resources/resources/person/sql/race.sql create mode 100644 src/main/resources/resources/person/sql/yearofbirth_data.sql create mode 100644 src/main/resources/resources/person/sql/yearofbirth_stats.sql create mode 100644 src/test/java/org/ohdsi/webapi/test/CharacterizationServiceIT.java diff --git a/.gitignore b/.gitignore index 1bd4b56257..72262c6d05 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ *application.properties +.idea/ +*.iml sandbox/ /target/ .settings diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000000..d518f1f385 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/ohdsi/webapi/DataAccessConfig.java b/src/main/java/org/ohdsi/webapi/DataAccessConfig.java index 24e2200de6..f24df94abc 100644 --- a/src/main/java/org/ohdsi/webapi/DataAccessConfig.java +++ b/src/main/java/org/ohdsi/webapi/DataAccessConfig.java @@ -28,97 +28,97 @@ @EnableTransactionManagement public class DataAccessConfig { - @Autowired - private Environment env; + @Autowired + private Environment env; - - private Properties getJPAProperties() { - Properties properties = new Properties(); - properties.setProperty("hibernate.default_schema", this.env.getProperty("spring.jpa.properties.hibernate.default_schema")); - return properties; - } - - @Bean - @Primary - public DataSource primaryDataSource() { - - String driver = this.env.getRequiredProperty("datasource.driverClassName"); - String url = this.env.getRequiredProperty("datasource.url"); - String user = this.env.getRequiredProperty("datasource.username"); - String pass = this.env.getRequiredProperty("datasource.password"); - boolean autoCommit = false; + + private Properties getJPAProperties() { + Properties properties = new Properties(); + properties.setProperty("hibernate.default_schema", this.env.getProperty("spring.jpa.properties.hibernate.default_schema")); + return properties; + } + + @Bean + @Primary + public DataSource primaryDataSource() { + + String driver = this.env.getRequiredProperty("datasource.driverClassName"); + String url = this.env.getRequiredProperty("datasource.url"); + String user = this.env.getRequiredProperty("datasource.username"); + String pass = this.env.getRequiredProperty("datasource.password"); + boolean autoCommit = false; //pooling - currently issues with (at least) oracle with use of temp tables and "on commit preserve rows" instead of "on commit delete rows"; - //http://forums.ohdsi.org/t/transaction-vs-session-scope-for-global-temp-tables-statements/333/2 + //http://forums.ohdsi.org/t/transaction-vs-session-scope-for-global-temp-tables-statements/333/2 /*final PoolConfiguration pc = new org.apache.tomcat.jdbc.pool.PoolProperties(); pc.setDriverClassName(driver); pc.setUrl(url); pc.setUsername(user); pc.setPassword(pass); pc.setDefaultAutoCommit(autoCommit);*/ - //non-pooling - DriverManagerDataSource ds = new DriverManagerDataSource(url, user, pass); - ds.setDriverClassName(driver); + //non-pooling + DriverManagerDataSource ds = new DriverManagerDataSource(url, user, pass); + ds.setDriverClassName(driver); //note autocommit defaults vary across vendors. use provided @Autowired TransactionTemplate - String[] supportedDrivers; - supportedDrivers = new String[]{"org.postgresql.Driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "oracle.jdbc.driver.OracleDriver", "com.amazon.redshift.jdbc41.Driver"}; - - for (String driverName : supportedDrivers) { - try { - Class.forName(driverName); - System.out.println("driver loaded: " + driverName); - } catch (Exception ex) { - System.out.println("error loading " + driverName + " driver."); - } + String[] supportedDrivers; + supportedDrivers = new String[]{"org.postgresql.Driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "oracle.jdbc.driver.OracleDriver", "com.amazon.redshift.jdbc41.Driver"}; + + for (String driverName : supportedDrivers) { + try { + Class.forName(driverName); + System.out.println("driver loaded: " + driverName); + } catch (Exception ex) { + System.out.println("error loading " + driverName + " driver."); + } + } + return ds; + //return new org.apache.tomcat.jdbc.pool.DataSource(pc); } - return ds; - //return new org.apache.tomcat.jdbc.pool.DataSource(pc); - } - @Bean - public EntityManagerFactory entityManagerFactory() { + @Bean + public EntityManagerFactory entityManagerFactory() { - HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - vendorAdapter.setGenerateDdl(false); - vendorAdapter.setShowSql(Boolean.valueOf(this.env.getRequiredProperty("spring.jpa.show-sql"))); + HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + vendorAdapter.setGenerateDdl(false); + vendorAdapter.setShowSql(Boolean.valueOf(this.env.getRequiredProperty("spring.jpa.show-sql"))); //hibernate.dialect is resolved based on driver - //vendorAdapter.setDatabasePlatform(hibernateDialect); - - LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); - factory.setJpaVendorAdapter(vendorAdapter); - factory.setJpaProperties(getJPAProperties()); - factory.setPackagesToScan("org.ohdsi.webapi"); - factory.setDataSource(primaryDataSource()); - factory.afterPropertiesSet(); - - return factory.getObject(); - } - - @Bean - @Primary - //This is needed so that JpaTransactionManager is used for autowiring, instead of DataSourceTransactionManager - public PlatformTransactionManager jpaTransactionManager() {//EntityManagerFactory entityManagerFactory) { - - JpaTransactionManager txManager = new JpaTransactionManager(); - txManager.setEntityManagerFactory(entityManagerFactory()); - return txManager; - } - - @Bean - public TransactionTemplate transactionTemplate(PlatformTransactionManager transactionManager) { - TransactionTemplate transactionTemplate = new TransactionTemplate(); - transactionTemplate.setTransactionManager(transactionManager); - return transactionTemplate; - } - - @Bean - public TransactionTemplate transactionTemplateRequiresNew(PlatformTransactionManager transactionManager) { - TransactionTemplate transactionTemplate = new TransactionTemplate(); - transactionTemplate.setTransactionManager(transactionManager); - transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); - return transactionTemplate; - } + //vendorAdapter.setDatabasePlatform(hibernateDialect); + + LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); + factory.setJpaVendorAdapter(vendorAdapter); + factory.setJpaProperties(getJPAProperties()); + factory.setPackagesToScan("org.ohdsi.webapi"); + factory.setDataSource(primaryDataSource()); + factory.afterPropertiesSet(); + + return factory.getObject(); + } + + @Bean + @Primary + //This is needed so that JpaTransactionManager is used for autowiring, instead of DataSourceTransactionManager + public PlatformTransactionManager jpaTransactionManager() {//EntityManagerFactory entityManagerFactory) { + + JpaTransactionManager txManager = new JpaTransactionManager(); + txManager.setEntityManagerFactory(entityManagerFactory()); + return txManager; + } + + @Bean + public TransactionTemplate transactionTemplate(PlatformTransactionManager transactionManager) { + TransactionTemplate transactionTemplate = new TransactionTemplate(); + transactionTemplate.setTransactionManager(transactionManager); + return transactionTemplate; + } + + @Bean + public TransactionTemplate transactionTemplateRequiresNew(PlatformTransactionManager transactionManager) { + TransactionTemplate transactionTemplate = new TransactionTemplate(); + transactionTemplate.setTransactionManager(transactionManager); + transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); + return transactionTemplate; + } /* public String getSparqlEndpoint() diff --git a/src/main/java/org/ohdsi/webapi/cohortresults/VisualizationData.java b/src/main/java/org/ohdsi/webapi/cohortresults/VisualizationData.java index 0833d9be9c..fa01255774 100644 --- a/src/main/java/org/ohdsi/webapi/cohortresults/VisualizationData.java +++ b/src/main/java/org/ohdsi/webapi/cohortresults/VisualizationData.java @@ -10,133 +10,133 @@ import javax.persistence.Table; @Entity(name = "VisualizationData") -@Table(name="heracles_visualization_data") +@Table(name = "heracles_visualization_data") public class VisualizationData implements Serializable { - /** - * - */ - private static final long serialVersionUID = -567692689983359944L; - - @Id - @GeneratedValue - @Column(name="ID") - private int id; - - @Column(name="COHORT_DEFINITION_ID") - private int cohortDefinitionId; - - @Column(name="SOURCE_ID") - private int sourceId; - - @Column(name="VISUALIZATION_KEY") - private String visualizationKey; - - @Column(name="DATA") - private String data; - - @Column(name="END_TIME") - private Date endTime; - - @Column(name="DRILLDOWN_ID") - private int drilldownId; - - /** - * @return the id - */ - public int getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(int id) { - this.id = id; - } - - /** - * @return the cohortDefinitionId - */ - public int getCohortDefinitionId() { - return cohortDefinitionId; - } - - /** - * @param cohortDefinitionId the cohortDefinitionId to set - */ - public void setCohortDefinitionId(int cohortDefinitionId) { - this.cohortDefinitionId = cohortDefinitionId; - } - - /** - * @return the source_id - */ - public int getSourceId() { - return sourceId; - } - - /** - * @param source_id the source_id to set - */ - public void setSourceId(int sourceId) { - this.sourceId = sourceId; - } - - /** - * @return the visualizationKey - */ - public String getVisualizationKey() { - return visualizationKey; - } - - /** - * @param visualizationKey the visualizationKey to set - */ - public void setVisualizationKey(String visualizationKey) { - this.visualizationKey = visualizationKey; - } - - /** - * @return the data - */ - public String getData() { - return data; - } - - /** - * @param data the data to set - */ - public void setData(String data) { - this.data = data; - } - - /** - * @return the endTime - */ - public Date getEndTime() { - return endTime; - } - - /** - * @param endTime the endTime to set - */ - public void setEndTime(Date endTime) { - this.endTime = endTime; - } - - /** - * @return the drilldownId - */ - public int getDrilldownId() { - return drilldownId; - } - - /** - * @param drilldownId the drilldownId to set - */ - public void setDrilldownId(int drilldownId) { - this.drilldownId = drilldownId; - } - + /** + * + */ + private static final long serialVersionUID = -567692689983359944L; + + @Id + @GeneratedValue + @Column(name = "ID") + private int id; + + @Column(name = "COHORT_DEFINITION_ID") + private int cohortDefinitionId; + + @Column(name = "SOURCE_ID") + private int sourceId; + + @Column(name = "VISUALIZATION_KEY") + private String visualizationKey; + + @Column(name = "DATA") + private String data; + + @Column(name = "END_TIME") + private Date endTime; + + @Column(name = "DRILLDOWN_ID") + private int drilldownId; + + /** + * @return the id + */ + public int getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return the cohortDefinitionId + */ + public int getCohortDefinitionId() { + return cohortDefinitionId; + } + + /** + * @param cohortDefinitionId the cohortDefinitionId to set + */ + public void setCohortDefinitionId(int cohortDefinitionId) { + this.cohortDefinitionId = cohortDefinitionId; + } + + /** + * @return the source_id + */ + public int getSourceId() { + return sourceId; + } + + /** + * @param source_id the source_id to set + */ + public void setSourceId(int sourceId) { + this.sourceId = sourceId; + } + + /** + * @return the visualizationKey + */ + public String getVisualizationKey() { + return visualizationKey; + } + + /** + * @param visualizationKey the visualizationKey to set + */ + public void setVisualizationKey(String visualizationKey) { + this.visualizationKey = visualizationKey; + } + + /** + * @return the data + */ + public String getData() { + return data; + } + + /** + * @param data the data to set + */ + public void setData(String data) { + this.data = data; + } + + /** + * @return the endTime + */ + public Date getEndTime() { + return endTime; + } + + /** + * @param endTime the endTime to set + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * @return the drilldownId + */ + public int getDrilldownId() { + return drilldownId; + } + + /** + * @param drilldownId the drilldownId to set + */ + public void setDrilldownId(int drilldownId) { + this.drilldownId = drilldownId; + } + } diff --git a/src/main/java/org/ohdsi/webapi/report/CDMAchillesHeel.java b/src/main/java/org/ohdsi/webapi/report/CDMAchillesHeel.java new file mode 100644 index 0000000000..a87adc8a99 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CDMAchillesHeel.java @@ -0,0 +1,7 @@ +package org.ohdsi.webapi.report; + +/** + * Created by taa7016 on 10/4/2016. + */ +public class CDMAchillesHeel { +} diff --git a/src/main/java/org/ohdsi/webapi/report/CDMCondition.java b/src/main/java/org/ohdsi/webapi/report/CDMCondition.java new file mode 100644 index 0000000000..d3fe2b0575 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CDMCondition.java @@ -0,0 +1,7 @@ +package org.ohdsi.webapi.report; + +/** + * Created by taa7016 on 10/4/2016. + */ +public class CDMCondition { +} diff --git a/src/main/java/org/ohdsi/webapi/report/CDMConditionEra.java b/src/main/java/org/ohdsi/webapi/report/CDMConditionEra.java new file mode 100644 index 0000000000..bd5f086080 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CDMConditionEra.java @@ -0,0 +1,7 @@ +package org.ohdsi.webapi.report; + +/** + * Created by taa7016 on 10/4/2016. + */ +public class CDMConditionEra { +} diff --git a/src/main/java/org/ohdsi/webapi/report/CDMDashboard.java b/src/main/java/org/ohdsi/webapi/report/CDMDashboard.java new file mode 100644 index 0000000000..3c41892aad --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CDMDashboard.java @@ -0,0 +1,63 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CDMDashboard { + + private List gender; + private List ageAtFirstObservation; + private List cumulativeObservation; + private List observedByMonth; + /** + * @return the gender + */ + public List getGender() { + return gender; + } + /** + * @param gender the gender to set + */ + public void setGender(List gender) { + this.gender = gender; + } + /** + * @return the ageAtFirstObservation + */ + public List getAgeAtFirstObservation() { + return ageAtFirstObservation; + } + /** + * @param ageAtFirstObservation the ageAtFirstObservation to set + */ + public void setAgeAtFirstObservation( + List ageAtFirstObservation) { + this.ageAtFirstObservation = ageAtFirstObservation; + } + /** + * @return the cumulativeObservation + */ + public List getCumulativeObservation() { + return cumulativeObservation; + } + /** + * @param cumulativeObservation the cumulativeObservation to set + */ + public void setCumulativeObservation( + List cumulativeObservation) { + this.cumulativeObservation = cumulativeObservation; + } + /** + * @return the observedByMonth + */ + public List getObservedByMonth() { + return observedByMonth; + } + /** + * @param observedByMonth the observedByMonth to set + */ + public void setObservedByMonth(List observedByMonth) { + this.observedByMonth = observedByMonth; + } + + +} diff --git a/src/main/java/org/ohdsi/webapi/report/CDMDataDensity.java b/src/main/java/org/ohdsi/webapi/report/CDMDataDensity.java new file mode 100644 index 0000000000..8e98ccbfc8 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CDMDataDensity.java @@ -0,0 +1,7 @@ +package org.ohdsi.webapi.report; + +/** + * Created by taa7016 on 10/4/2016. + */ +public class CDMDataDensity { +} diff --git a/src/main/java/org/ohdsi/webapi/report/CDMDrugSummary.java b/src/main/java/org/ohdsi/webapi/report/CDMDrugSummary.java new file mode 100644 index 0000000000..d78ae33cca --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CDMDrugSummary.java @@ -0,0 +1,7 @@ +package org.ohdsi.webapi.report; + +/** + * Created by taa7016 on 8/29/2016. + */ +public class CDMDrugSummary { +} diff --git a/src/main/java/org/ohdsi/webapi/report/CDMObservation.java b/src/main/java/org/ohdsi/webapi/report/CDMObservation.java new file mode 100644 index 0000000000..f067550814 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CDMObservation.java @@ -0,0 +1,7 @@ +package org.ohdsi.webapi.report; + +/** + * Created by taa7016 on 10/4/2016. + */ +public class CDMObservation { +} diff --git a/src/main/java/org/ohdsi/webapi/report/CDMObservationPeriod.java b/src/main/java/org/ohdsi/webapi/report/CDMObservationPeriod.java new file mode 100644 index 0000000000..d54b09ade1 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CDMObservationPeriod.java @@ -0,0 +1,7 @@ +package org.ohdsi.webapi.report; + +/** + * Created by taa7016 on 10/4/2016. + */ +public class CDMObservationPeriod { +} diff --git a/src/main/java/org/ohdsi/webapi/report/CDMPersonSummary.java b/src/main/java/org/ohdsi/webapi/report/CDMPersonSummary.java new file mode 100644 index 0000000000..bfe395ddd5 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CDMPersonSummary.java @@ -0,0 +1,79 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +/** + * Created by taa7016 on 8/12/2016. + */ +public class CDMPersonSummary { + + private List yearOfBirth; + private List yearOfBirthStats; + + private List gender; + private List race; + private List ethnicity; + + /** + * @return the YearOfBirth + */ + public List getYearOfBirth() { + return yearOfBirth; + } + /** + * @param YearOfBirth the YearOfBirth to set + */ + public void setYearOfBirth( + List yearOfBirth) { + this.yearOfBirth = yearOfBirth; + } + /** + * @return the Summary + */ + public List getSummary() { + return yearOfBirthStats; + } + /** + * @param yearOfBirthStats the yearOfBirthStats to set + */ + public void setSummary(List yearOfBirthStats) { + this.yearOfBirthStats = yearOfBirthStats; + } + /** + * @return the gender + */ + public List getGender() { + return gender; + } + /** + * @param gender the gender to set + */ + public void setGender(List gender) { + this.gender = gender; + } + /** + * @return the race + */ + public List getRace() { + return race; + } + /** + * @param race the race to set + */ + public void setRace(List race) { + this.race = race; + } + /** + * @return the ethnicity + */ + public List getEthnicity() { + return ethnicity; + } + /** + * @param ethnicity the ethnicity to set + */ + public void setEthnicity(List ethnicity) { + this.ethnicity = ethnicity; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/CDMProcedureSummary.java b/src/main/java/org/ohdsi/webapi/report/CDMProcedureSummary.java new file mode 100644 index 0000000000..3b7ea2ed31 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CDMProcedureSummary.java @@ -0,0 +1,7 @@ +package org.ohdsi.webapi.report; + +/** + * Created by taa7016 on 8/29/2016. + */ +public class CDMProcedureSummary { +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortAttribute.java b/src/main/java/org/ohdsi/webapi/report/CohortAttribute.java new file mode 100644 index 0000000000..ee2951045a --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortAttribute.java @@ -0,0 +1,33 @@ +package org.ohdsi.webapi.report; + +public class CohortAttribute { + private String attributeName; + private String attributeValue; + + /** + * @return the attributeName + */ + public String getAttributeName() { + return attributeName; + } + /** + * @param attributeName the attributeName to set + */ + public void setAttributeName(String attributeName) { + this.attributeName = attributeName; + } + /** + * @return the attributeValue + */ + public String getAttributeValue() { + return attributeValue; + } + /** + * @param attributeValue the attributeValue to set + */ + public void setAttributeValue(String attributeValue) { + this.attributeValue = attributeValue; + } + + +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortBreakdown.java b/src/main/java/org/ohdsi/webapi/report/CohortBreakdown.java new file mode 100644 index 0000000000..974139b941 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortBreakdown.java @@ -0,0 +1,18 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.ohdsi.webapi.report; + +/** + * + * @author sgold1 + */ +public class CohortBreakdown { + public Long people; // count + public String gender; + public String age; // e.g. "30-39" + public Long conditions; // count + public Long drugs; // count +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortConditionDrilldown.java b/src/main/java/org/ohdsi/webapi/report/CohortConditionDrilldown.java new file mode 100644 index 0000000000..72a0f79c8c --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortConditionDrilldown.java @@ -0,0 +1,70 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortConditionDrilldown { + private List ageAtFirstDiagnosis; + + private List conditionsByType; + + private List prevalenceByGenderAgeYear; + + private List prevalenceByMonth; + + /** + * @return the ageAtFirstDiagnosis + */ + public List getAgeAtFirstDiagnosis() { + return ageAtFirstDiagnosis; + } + + /** + * @param ageAtFirstDiagnosis the ageAtFirstDiagnosis to set + */ + public void setAgeAtFirstDiagnosis(List ageAtFirstDiagnosis) { + this.ageAtFirstDiagnosis = ageAtFirstDiagnosis; + } + + /** + * @return the conditionsByType + */ + public List getConditionsByType() { + return conditionsByType; + } + + /** + * @param conditionsByType the conditionsByType to set + */ + public void setConditionsByType(List conditionsByType) { + this.conditionsByType = conditionsByType; + } + + /** + * @return the prevalenceByGenderAgeYear + */ + public List getPrevalenceByGenderAgeYear() { + return prevalenceByGenderAgeYear; + } + + /** + * @param prevalenceByGenderAgeYear the prevalenceByGenderAgeYear to set + */ + public void setPrevalenceByGenderAgeYear( + List prevalenceByGenderAgeYear) { + this.prevalenceByGenderAgeYear = prevalenceByGenderAgeYear; + } + + /** + * @return the prevalenceByMonth + */ + public List getPrevalenceByMonth() { + return prevalenceByMonth; + } + + /** + * @param prevalenceByMonth the prevalenceByMonth to set + */ + public void setPrevalenceByMonth(List prevalenceByMonth) { + this.prevalenceByMonth = prevalenceByMonth; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortConditionEraDrilldown.java b/src/main/java/org/ohdsi/webapi/report/CohortConditionEraDrilldown.java new file mode 100644 index 0000000000..78aed96c5a --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortConditionEraDrilldown.java @@ -0,0 +1,62 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortConditionEraDrilldown { + + private List ageAtFirstDiagnosis; + private List lengthOfEra; + private List prevalenceByGenderAgeYear; + private List prevalenceByMonth; + + /** + * @return the ageAtFirstDiagnosis + */ + public List getAgeAtFirstDiagnosis() { + return ageAtFirstDiagnosis; + } + /** + * @param ageAtFirstDiagnosis the ageAtFirstDiagnosis to set + */ + public void setAgeAtFirstDiagnosis(List ageAtFirstDiagnosis) { + this.ageAtFirstDiagnosis = ageAtFirstDiagnosis; + } + /** + * @return the lengthOfEra + */ + public List getLengthOfEra() { + return lengthOfEra; + } + /** + * @param lengthOfEra the lengthOfEra to set + */ + public void setLengthOfEra(List lengthOfEra) { + this.lengthOfEra = lengthOfEra; + } + /** + * @return the prevalenceByGenderAgeYear + */ + public List getPrevalenceByGenderAgeYear() { + return prevalenceByGenderAgeYear; + } + /** + * @param prevalenceByGenderAgeYear the prevalenceByGenderAgeYear to set + */ + public void setPrevalenceByGenderAgeYear( + List prevalenceByGenderAgeYear) { + this.prevalenceByGenderAgeYear = prevalenceByGenderAgeYear; + } + /** + * @return the prevalenceByMonth + */ + public List getPrevalenceByMonth() { + return prevalenceByMonth; + } + /** + * @param prevalenceByMonth the prevalenceByMonth to set + */ + public void setPrevalenceByMonth(List prevalenceByMonth) { + this.prevalenceByMonth = prevalenceByMonth; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortDataDensity.java b/src/main/java/org/ohdsi/webapi/report/CohortDataDensity.java new file mode 100644 index 0000000000..bfde79b73f --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortDataDensity.java @@ -0,0 +1,47 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortDataDensity { + + private List recordsPerPerson; + private List totalRecords; + private List conceptsPerPerson; + + /** + * @return the recordsPerPerson + */ + public List getRecordsPerPerson() { + return recordsPerPerson; + } + /** + * @param recordsPerPerson the recordsPerPerson to set + */ + public void setRecordsPerPerson(List recordsPerPerson) { + this.recordsPerPerson = recordsPerPerson; + } + /** + * @return the totalRecords + */ + public List getTotalRecords() { + return totalRecords; + } + /** + * @param totalRecords the totalRecords to set + */ + public void setTotalRecords(List totalRecords) { + this.totalRecords = totalRecords; + } + /** + * @return the conceptsPerPerson + */ + public List getConceptsPerPerson() { + return conceptsPerPerson; + } + /** + * @param conceptsPerPerson the conceptsPerPerson to set + */ + public void setConceptsPerPerson(List conceptsPerPerson) { + this.conceptsPerPerson = conceptsPerPerson; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortDeathData.java b/src/main/java/org/ohdsi/webapi/report/CohortDeathData.java new file mode 100644 index 0000000000..bdfc141f21 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortDeathData.java @@ -0,0 +1,72 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortDeathData { + private List agetAtDeath; + + private List deathByType; + + private List prevalenceByGenderAgeYear; + + private List prevalenceByMonth; + + /** + * @return the agetAtDeath + */ + public List getAgetAtDeath() { + return agetAtDeath; + } + + /** + * @param agetAtDeath the agetAtDeath to set + */ + public void setAgetAtDeath(List agetAtDeath) { + this.agetAtDeath = agetAtDeath; + } + + /** + * @return the deathByType + */ + public List getDeathByType() { + return deathByType; + } + + /** + * @param deathByType the deathByType to set + */ + public void setDeathByType(List deathByType) { + this.deathByType = deathByType; + } + + /** + * @return the prevalenceByGenderAgeYear + */ + public List getPrevalenceByGenderAgeYear() { + return prevalenceByGenderAgeYear; + } + + /** + * @param prevalenceByGenderAgeYear the prevalenceByGenderAgeYear to set + */ + public void setPrevalenceByGenderAgeYear( + List prevalenceByGenderAgeYear) { + this.prevalenceByGenderAgeYear = prevalenceByGenderAgeYear; + } + + /** + * @return the prevalenceByMonth + */ + public List getPrevalenceByMonth() { + return prevalenceByMonth; + } + + /** + * @param prevalenceByMonth the prevalenceByMonth to set + */ + public void setPrevalenceByMonth(List prevalenceByMonth) { + this.prevalenceByMonth = prevalenceByMonth; + } + + +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortDrugDrilldown.java b/src/main/java/org/ohdsi/webapi/report/CohortDrugDrilldown.java new file mode 100644 index 0000000000..9170b3fc44 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortDrugDrilldown.java @@ -0,0 +1,103 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortDrugDrilldown { + private List ageAtFirstExposure; + private List daysSupplyDistribution; + private List drugsByType; + private List prevalenceByGenderAgeYear; + private List prevalenceByMonth; + private List quantityDistribution; + private List refillsDistribution; + + /** + * @return the ageAtFirstExposure + */ + public List getAgeAtFirstExposure() { + return ageAtFirstExposure; + } + /** + * @param ageAtFirstExposure the ageAtFirstExposure to set + */ + public void setAgeAtFirstExposure(List ageAtFirstExposure) { + this.ageAtFirstExposure = ageAtFirstExposure; + } + /** + * @return the daysSupplyDistribution + */ + public List getDaysSupplyDistribution() { + return daysSupplyDistribution; + } + /** + * @param daysSupplyDistribution the daysSupplyDistribution to set + */ + public void setDaysSupplyDistribution( + List daysSupplyDistribution) { + this.daysSupplyDistribution = daysSupplyDistribution; + } + /** + * @return the drugsByType + */ + public List getDrugsByType() { + return drugsByType; + } + /** + * @param drugsByType the drugsByType to set + */ + public void setDrugsByType(List drugsByType) { + this.drugsByType = drugsByType; + } + /** + * @return the prevalenceByGenderAgeYear + */ + public List getPrevalenceByGenderAgeYear() { + return prevalenceByGenderAgeYear; + } + /** + * @param prevalenceByGenderAgeYear the prevalenceByGenderAgeYear to set + */ + public void setPrevalenceByGenderAgeYear( + List prevalenceByGenderAgeYear) { + this.prevalenceByGenderAgeYear = prevalenceByGenderAgeYear; + } + /** + * @return the prevalenceByMonth + */ + public List getPrevalenceByMonth() { + return prevalenceByMonth; + } + /** + * @param prevalenceByMonth the prevalenceByMonth to set + */ + public void setPrevalenceByMonth(List prevalenceByMonth) { + this.prevalenceByMonth = prevalenceByMonth; + } + /** + * @return the quantityDistribution + */ + public List getQuantityDistribution() { + return quantityDistribution; + } + /** + * @param quantityDistribution the quantityDistribution to set + */ + public void setQuantityDistribution( + List quantityDistribution) { + this.quantityDistribution = quantityDistribution; + } + /** + * @return the refillsDistribution + */ + public List getRefillsDistribution() { + return refillsDistribution; + } + /** + * @param refillsDistribution the refillsDistribution to set + */ + public void setRefillsDistribution( + List refillsDistribution) { + this.refillsDistribution = refillsDistribution; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortDrugEraDrilldown.java b/src/main/java/org/ohdsi/webapi/report/CohortDrugEraDrilldown.java new file mode 100644 index 0000000000..3a0ccc8d5b --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortDrugEraDrilldown.java @@ -0,0 +1,61 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortDrugEraDrilldown { + private List ageAtFirstExposure; + private List lengthOfEra; + private List prevalenceByGenderAgeYear; + private List prevalenceByMonth; + /** + * @return the ageAtFirstExposure + */ + public List getAgeAtFirstExposure() { + return ageAtFirstExposure; + } + /** + * @param ageAtFirstExposure the ageAtFirstExposure to set + */ + public void setAgeAtFirstExposure(List ageAtFirstExposure) { + this.ageAtFirstExposure = ageAtFirstExposure; + } + /** + * @return the lengthOfEra + */ + public List getLengthOfEra() { + return lengthOfEra; + } + /** + * @param lengthOfEra the lengthOfEra to set + */ + public void setLengthOfEra(List lengthOfEra) { + this.lengthOfEra = lengthOfEra; + } + /** + * @return the prevalenceByGenderAgeYear + */ + public List getPrevalenceByGenderAgeYear() { + return prevalenceByGenderAgeYear; + } + /** + * @param prevalenceByGenderAgeYear the prevalenceByGenderAgeYear to set + */ + public void setPrevalenceByGenderAgeYear( + List prevalenceByGenderAgeYear) { + this.prevalenceByGenderAgeYear = prevalenceByGenderAgeYear; + } + /** + * @return the prevalenceByMonth + */ + public List getPrevalenceByMonth() { + return prevalenceByMonth; + } + /** + * @param prevalenceByMonth the prevalenceByMonth to set + */ + public void setPrevalenceByMonth(List prevalenceByMonth) { + this.prevalenceByMonth = prevalenceByMonth; + } + + +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortMeasurementDrilldown.java b/src/main/java/org/ohdsi/webapi/report/CohortMeasurementDrilldown.java new file mode 100644 index 0000000000..7bbaf00307 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortMeasurementDrilldown.java @@ -0,0 +1,133 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortMeasurementDrilldown { + private List ageAtFirstOccurrence; + private List lowerLimitDistribution; + private List measurementValueDistribution; + private List upperLimitDistribution; + + private List observationsByType; + private List recordsByUnit; + private List valuesRelativeToNorm; + + private List prevalenceByGenderAgeYear; + + private List prevalenceByMonth; + + /** + * @return the ageAtFirstOccurrence + */ + public List getAgeAtFirstOccurrence() { + return ageAtFirstOccurrence; + } + /** + * @param ageAtFirstOccurrence the ageAtFirstOccurrence to set + */ + public void setAgeAtFirstOccurrence( + List ageAtFirstOccurrence) { + this.ageAtFirstOccurrence = ageAtFirstOccurrence; + } + /** + * @return the lowerLimitDistribution + */ + public List getLowerLimitDistribution() { + return lowerLimitDistribution; + } + /** + * @param lowerLimitDistribution the lowerLimitDistribution to set + */ + public void setLowerLimitDistribution( + List lowerLimitDistribution) { + this.lowerLimitDistribution = lowerLimitDistribution; + } + /** + * @return the observationsByType + */ + public List getMeasurementsByType() { + return observationsByType; + } + /** + * @param observationsByType the observationsByType to set + */ + public void setMeasurementsByType(List observationsByType) { + this.observationsByType = observationsByType; + } + /** + * @return the observationValueDistribution + */ + public List getMeasurementValueDistribution() { + return measurementValueDistribution; + } + /** + * @param observationValueDistribution the observationValueDistribution to set + */ + public void setMeasurementValueDistribution( + List observationValueDistribution) { + this.measurementValueDistribution = observationValueDistribution; + } + /** + * @return the prevalenceByGenderAgeYear + */ + public List getPrevalenceByGenderAgeYear() { + return prevalenceByGenderAgeYear; + } + /** + * @param prevalenceByGenderAgeYear the prevalenceByGenderAgeYear to set + */ + public void setPrevalenceByGenderAgeYear( + List prevalenceByGenderAgeYear) { + this.prevalenceByGenderAgeYear = prevalenceByGenderAgeYear; + } + /** + * @return the prevalenceByMonth + */ + public List getPrevalenceByMonth() { + return prevalenceByMonth; + } + /** + * @param prevalenceByMonth the prevalenceByMonth to set + */ + public void setPrevalenceByMonth(List prevalenceByMonth) { + this.prevalenceByMonth = prevalenceByMonth; + } + /** + * @return the recordsByUnit + */ + public List getRecordsByUnit() { + return recordsByUnit; + } + /** + * @param recordsByUnit the recordsByUnit to set + */ + public void setRecordsByUnit(List recordsByUnit) { + this.recordsByUnit = recordsByUnit; + } + /** + * @return the upperLimitDistribution + */ + public List getUpperLimitDistribution() { + return upperLimitDistribution; + } + /** + * @param upperLimitDistribution the upperLimitDistribution to set + */ + public void setUpperLimitDistribution( + List upperLimitDistribution) { + this.upperLimitDistribution = upperLimitDistribution; + } + /** + * @return the valuesRelativeToNorm + */ + public List getValuesRelativeToNorm() { + return valuesRelativeToNorm; + } + /** + * @param valuesRelativeToNorm the valuesRelativeToNorm to set + */ + public void setValuesRelativeToNorm( + List valuesRelativeToNorm) { + this.valuesRelativeToNorm = valuesRelativeToNorm; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortObservationDrilldown.java b/src/main/java/org/ohdsi/webapi/report/CohortObservationDrilldown.java new file mode 100644 index 0000000000..4155f2f8ff --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortObservationDrilldown.java @@ -0,0 +1,133 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortObservationDrilldown { + private List ageAtFirstOccurrence; + private List lowerLimitDistribution; + private List observationValueDistribution; + private List upperLimitDistribution; + + private List observationsByType; + private List recordsByUnit; + private List valuesRelativeToNorm; + + private List prevalenceByGenderAgeYear; + + private List prevalenceByMonth; + + /** + * @return the ageAtFirstOccurrence + */ + public List getAgeAtFirstOccurrence() { + return ageAtFirstOccurrence; + } + /** + * @param ageAtFirstOccurrence the ageAtFirstOccurrence to set + */ + public void setAgeAtFirstOccurrence( + List ageAtFirstOccurrence) { + this.ageAtFirstOccurrence = ageAtFirstOccurrence; + } + /** + * @return the lowerLimitDistribution + */ + public List getLowerLimitDistribution() { + return lowerLimitDistribution; + } + /** + * @param lowerLimitDistribution the lowerLimitDistribution to set + */ + public void setLowerLimitDistribution( + List lowerLimitDistribution) { + this.lowerLimitDistribution = lowerLimitDistribution; + } + /** + * @return the observationsByType + */ + public List getObservationsByType() { + return observationsByType; + } + /** + * @param observationsByType the observationsByType to set + */ + public void setObservationsByType(List observationsByType) { + this.observationsByType = observationsByType; + } + /** + * @return the observationValueDistribution + */ + public List getObservationValueDistribution() { + return observationValueDistribution; + } + /** + * @param observationValueDistribution the observationValueDistribution to set + */ + public void setObservationValueDistribution( + List observationValueDistribution) { + this.observationValueDistribution = observationValueDistribution; + } + /** + * @return the prevalenceByGenderAgeYear + */ + public List getPrevalenceByGenderAgeYear() { + return prevalenceByGenderAgeYear; + } + /** + * @param prevalenceByGenderAgeYear the prevalenceByGenderAgeYear to set + */ + public void setPrevalenceByGenderAgeYear( + List prevalenceByGenderAgeYear) { + this.prevalenceByGenderAgeYear = prevalenceByGenderAgeYear; + } + /** + * @return the prevalenceByMonth + */ + public List getPrevalenceByMonth() { + return prevalenceByMonth; + } + /** + * @param prevalenceByMonth the prevalenceByMonth to set + */ + public void setPrevalenceByMonth(List prevalenceByMonth) { + this.prevalenceByMonth = prevalenceByMonth; + } + /** + * @return the recordsByUnit + */ + public List getRecordsByUnit() { + return recordsByUnit; + } + /** + * @param recordsByUnit the recordsByUnit to set + */ + public void setRecordsByUnit(List recordsByUnit) { + this.recordsByUnit = recordsByUnit; + } + /** + * @return the upperLimitDistribution + */ + public List getUpperLimitDistribution() { + return upperLimitDistribution; + } + /** + * @param upperLimitDistribution the upperLimitDistribution to set + */ + public void setUpperLimitDistribution( + List upperLimitDistribution) { + this.upperLimitDistribution = upperLimitDistribution; + } + /** + * @return the valuesRelativeToNorm + */ + public List getValuesRelativeToNorm() { + return valuesRelativeToNorm; + } + /** + * @param valuesRelativeToNorm the valuesRelativeToNorm to set + */ + public void setValuesRelativeToNorm( + List valuesRelativeToNorm) { + this.valuesRelativeToNorm = valuesRelativeToNorm; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortObservationPeriod.java b/src/main/java/org/ohdsi/webapi/report/CohortObservationPeriod.java new file mode 100644 index 0000000000..1c5ede5916 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortObservationPeriod.java @@ -0,0 +1,162 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortObservationPeriod { + private List ageAtFirst; + private List observationLength; + private List personsWithContinuousObservationsByYear; + + private List personsWithContinuousObservationsByYearStats; + private List observationLengthStats; + + private List ageByGender; + private List durationByGender; + private List durationByAgeDecile; + + private List cumulativeObservation; + + private List observationPeriodsPerPerson; + + private List observedByMonth; + + /** + * @return the ageAtFirst + */ + public List getAgeAtFirst() { + return ageAtFirst; + } + /** + * @param ageAtFirst the ageAtFirst to set + */ + public void setAgeAtFirst(List ageAtFirst) { + this.ageAtFirst = ageAtFirst; + } + /** + * @return the ageByGender + */ + public List getAgeByGender() { + return ageByGender; + } + /** + * @param ageByGender the ageByGender to set + */ + public void setAgeByGender(List ageByGender) { + this.ageByGender = ageByGender; + } + /** + * @return the observationLength + */ + public List getObservationLength() { + return observationLength; + } + /** + * @param observationLength the observationLength to set + */ + public void setObservationLength( + List observationLength) { + this.observationLength = observationLength; + } + /** + * @return the durationByGender + */ + public List getDurationByGender() { + return durationByGender; + } + /** + * @param durationByGender the durationByGender to set + */ + public void setDurationByGender(List durationByGender) { + this.durationByGender = durationByGender; + } + /** + * @return the cumulativeObservation + */ + public List getCumulativeObservation() { + return cumulativeObservation; + } + /** + * @param cumulativeObservation the cumulativeObservation to set + */ + public void setCumulativeObservation( + List cumulativeObservation) { + this.cumulativeObservation = cumulativeObservation; + } + /** + * @return the durationByAgeDecile + */ + public List getDurationByAgeDecile() { + return durationByAgeDecile; + } + /** + * @param durationByAgeDecile the durationByAgeDecile to set + */ + public void setDurationByAgeDecile( + List durationByAgeDecile) { + this.durationByAgeDecile = durationByAgeDecile; + } + /** + * @return the personsWithContinuousObservationsByYear + */ + public List getPersonsWithContinuousObservationsByYear() { + return personsWithContinuousObservationsByYear; + } + /** + * @param personsWithContinuousObservationsByYear the personsWithContinuousObservationsByYear to set + */ + public void setPersonsWithContinuousObservationsByYear( + List personsWithContinuousObservationsByYear) { + this.personsWithContinuousObservationsByYear = personsWithContinuousObservationsByYear; + } + /** + * @return the observationPeriodsPerPerson + */ + public List getObservationPeriodsPerPerson() { + return observationPeriodsPerPerson; + } + /** + * @param observationPeriodsPerPerson the observationPeriodsPerPerson to set + */ + public void setObservationPeriodsPerPerson( + List observationPeriodsPerPerson) { + this.observationPeriodsPerPerson = observationPeriodsPerPerson; + } + /** + * @return the observedByMonth + */ + public List getObservedByMonth() { + return observedByMonth; + } + /** + * @param observedByMonth the observedByMonth to set + */ + public void setObservedByMonth(List observedByMonth) { + this.observedByMonth = observedByMonth; + } + /** + * @return the personsWithContinuousObservationsByYearStats + */ + public List getPersonsWithContinuousObservationsByYearStats() { + return personsWithContinuousObservationsByYearStats; + } + /** + * @param personsWithContinuousObservationsByYearStats the personsWithContinuousObservationsByYearStats to set + */ + public void setPersonsWithContinuousObservationsByYearStats( + List personsWithContinuousObservationsByYearStats) { + this.personsWithContinuousObservationsByYearStats = personsWithContinuousObservationsByYearStats; + } + /** + * @return the observationLengthStats + */ + public List getObservationLengthStats() { + return observationLengthStats; + } + /** + * @param observationLengthStats the observationLengthStats to set + */ + public void setObservationLengthStats( + List observationLengthStats) { + this.observationLengthStats = observationLengthStats; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortPersonSummary.java b/src/main/java/org/ohdsi/webapi/report/CohortPersonSummary.java new file mode 100644 index 0000000000..6e2d919db8 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortPersonSummary.java @@ -0,0 +1,76 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortPersonSummary { + private List yearOfBirth; + private List yearOfBirthStats; + + private List gender; + private List race; + private List ethnicity; + + /** + * @return the YearOfBirth + */ + public List getYearOfBirth() { + return yearOfBirth; + } + /** + * @param YearOfBirth the YearOfBirth to set + */ + public void setYearOfBirth( + List yearOfBirth) { + this.yearOfBirth = yearOfBirth; + } + /** + * @return the yearOfBirthStats + */ + public List getYearOfBirthStats() { + return yearOfBirthStats; + } + /** + * @param yearOfBirthStats the yearOfBirthStats to set + */ + public void setYearOfBirthStats(List yearOfBirthStats) { + this.yearOfBirthStats = yearOfBirthStats; + } + /** + * @return the gender + */ + public List getGender() { + return gender; + } + /** + * @param gender the gender to set + */ + public void setGender(List gender) { + this.gender = gender; + } + /** + * @return the race + */ + public List getRace() { + return race; + } + /** + * @param race the race to set + */ + public void setRace(List race) { + this.race = race; + } + /** + * @return the ethnicity + */ + public List getEthnicity() { + return ethnicity; + } + /** + * @param ethnicity the ethnicity to set + */ + public void setEthnicity(List ethnicity) { + this.ethnicity = ethnicity; + } + + +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortProceduresDrillDown.java b/src/main/java/org/ohdsi/webapi/report/CohortProceduresDrillDown.java new file mode 100644 index 0000000000..ace8d65320 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortProceduresDrillDown.java @@ -0,0 +1,71 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortProceduresDrillDown { + private List ageAtFirstOccurrence; + + private List proceduresByType; + + private List prevalenceByGenderAgeYear; + + private List prevalenceByMonth; + + /** + * @return the ageAtFirstOccurrence + */ + public List getAgeAtFirstOccurrence() { + return ageAtFirstOccurrence; + } + + /** + * @param ageAtFirstOccurrence the ageAtFirstOccurrence to set + */ + public void setAgeAtFirstOccurrence( + List ageAtFirstOccurrence) { + this.ageAtFirstOccurrence = ageAtFirstOccurrence; + } + + /** + * @return the proceduresByType + */ + public List getProceduresByType() { + return proceduresByType; + } + + /** + * @param proceduresByType the proceduresByType to set + */ + public void setProceduresByType(List proceduresByType) { + this.proceduresByType = proceduresByType; + } + + /** + * @return the prevalenceByGenderAgeYear + */ + public List getPrevalenceByGenderAgeYear() { + return prevalenceByGenderAgeYear; + } + + /** + * @param prevalenceByGenderAgeYear the prevalenceByGenderAgeYear to set + */ + public void setPrevalenceByGenderAgeYear( + List prevalenceByGenderAgeYear) { + this.prevalenceByGenderAgeYear = prevalenceByGenderAgeYear; + } + + /** + * @return the prevalenceByMonth + */ + public List getPrevalenceByMonth() { + return prevalenceByMonth; + } + + /** + * @param prevalenceByMonth the prevalenceByMonth to set + */ + public void setPrevalenceByMonth(List prevalenceByMonth) { + this.prevalenceByMonth = prevalenceByMonth; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortSpecificSummary.java b/src/main/java/org/ohdsi/webapi/report/CohortSpecificSummary.java new file mode 100644 index 0000000000..3ea149b126 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortSpecificSummary.java @@ -0,0 +1,119 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortSpecificSummary { + private List personsByDurationFromStartToEnd; + private List prevalenceByMonth; + private List numPersonsByCohortStartByGenderByAge; + private List ageAtIndexDistribution; + private List personsInCohortFromCohortStartToEnd; + private List distributionAgeCohortStartByCohortStartYear; + private List distributionAgeCohortStartByGender; + + /** + * @return the numPersonsByCohortStartByGenderByAge + */ + public List getNumPersonsByCohortStartByGenderByAge() { + return numPersonsByCohortStartByGenderByAge; + } + + /** + * @param numPersonsByCohortStartByGenderByAge the numPersonsByCohortStartByGenderByAge to set + */ + public void setNumPersonsByCohortStartByGenderByAge( + List numPersonsByCohortStartByGenderByAge) { + this.numPersonsByCohortStartByGenderByAge = numPersonsByCohortStartByGenderByAge; + } + + /** + * @return the personsByDurationFromStartToEnd + */ + public List getPersonsByDurationFromStartToEnd() { + return personsByDurationFromStartToEnd; + } + + /** + * @param personsByDurationFromStartToEnd the personsByDurationFromStartToEnd to set + */ + public void setPersonsByDurationFromStartToEnd( + List personsByDurationFromStartToEnd) { + this.personsByDurationFromStartToEnd = personsByDurationFromStartToEnd; + } + + /** + * @return the prevalenceByMonth + */ + public List getPrevalenceByMonth() { + return prevalenceByMonth; + } + + /** + * @param prevalenceByMonth the prevalenceByMonth to set + */ + public void setPrevalenceByMonth(List prevalenceByMonth) { + this.prevalenceByMonth = prevalenceByMonth; + } + + /** + * @return the ageAtIndexDistribution + */ + public List getAgeAtIndexDistribution() { + return ageAtIndexDistribution; + } + + /** + * @param ageAtIndexDistribution the ageAtIndexDistribution to set + */ + public void setAgeAtIndexDistribution( + List ageAtIndexDistribution) { + this.ageAtIndexDistribution = ageAtIndexDistribution; + } + + /** + * @return the personsInCohortFromCohortStartToEnd + */ + public List getPersonsInCohortFromCohortStartToEnd() { + return personsInCohortFromCohortStartToEnd; + } + + /** + * @param personsInCohortFromCohortStartToEnd the personsInCohortFromCohortStartToEnd to set + */ + public void setPersonsInCohortFromCohortStartToEnd( + List personsInCohortFromCohortStartToEnd) { + this.personsInCohortFromCohortStartToEnd = personsInCohortFromCohortStartToEnd; + } + + /** + * @return the distributionAgeCohortStartByCohortStartYear + */ + public List getDistributionAgeCohortStartByCohortStartYear() { + return distributionAgeCohortStartByCohortStartYear; + } + + /** + * @param distributionAgeCohortStartByCohortStartYear the distributionAgeCohortStartByCohortStartYear to set + */ + public void setDistributionAgeCohortStartByCohortStartYear( + List distributionAgeCohortStartByCohortStartYear) { + this.distributionAgeCohortStartByCohortStartYear = distributionAgeCohortStartByCohortStartYear; + } + + /** + * @return the distributionAgeCohortStartByGender + */ + public List getDistributionAgeCohortStartByGender() { + return distributionAgeCohortStartByGender; + } + + /** + * @param distributionAgeCohortStartByGender the distributionAgeCohortStartByGender to set + */ + public void setDistributionAgeCohortStartByGender( + List distributionAgeCohortStartByGender) { + this.distributionAgeCohortStartByGender = distributionAgeCohortStartByGender; + } + + +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortSpecificTreemap.java b/src/main/java/org/ohdsi/webapi/report/CohortSpecificTreemap.java new file mode 100644 index 0000000000..d30b0bb0b8 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortSpecificTreemap.java @@ -0,0 +1,51 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortSpecificTreemap { + private List conditionOccurrencePrevalence; + private List procedureOccurrencePrevalence; + private List drugEraPrevalence; + + /** + * @return the conditionOccurrencePrevalence + */ + public List getConditionOccurrencePrevalence() { + return conditionOccurrencePrevalence; + } + /** + * @param conditionOccurrencePrevalence the conditionOccurrencePrevalence to set + */ + public void setConditionOccurrencePrevalence( + List conditionOccurrencePrevalence) { + this.conditionOccurrencePrevalence = conditionOccurrencePrevalence; + } + /** + * @return the procedureOccurrencePrevalence + */ + public List getProcedureOccurrencePrevalence() { + return procedureOccurrencePrevalence; + } + /** + * @param procedureOccurrencePrevalence the procedureOccurrencePrevalence to set + */ + public void setProcedureOccurrencePrevalence( + List procedureOccurrencePrevalence) { + this.procedureOccurrencePrevalence = procedureOccurrencePrevalence; + } + /** + * @return the drugEraPrevalence + */ + public List getDrugEraPrevalence() { + return drugEraPrevalence; + } + /** + * @param drugEraPrevalence the drugEraPrevalence to set + */ + public void setDrugEraPrevalence( + List drugEraPrevalence) { + this.drugEraPrevalence = drugEraPrevalence; + } + + +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortStatsRecord.java b/src/main/java/org/ohdsi/webapi/report/CohortStatsRecord.java new file mode 100644 index 0000000000..9a493a75bd --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortStatsRecord.java @@ -0,0 +1,45 @@ +package org.ohdsi.webapi.report; + +public class CohortStatsRecord { + + private int minValue; + private int maxValue; + private int intervalSize; + + /** + * @return the minValue + */ + public int getMinValue() { + return minValue; + } + /** + * @param minValue the minValue to set + */ + public void setMinValue(int minValue) { + this.minValue = minValue; + } + /** + * @return the maxValue + */ + public int getMaxValue() { + return maxValue; + } + /** + * @param maxValue the maxValue to set + */ + public void setMaxValue(int maxValue) { + this.maxValue = maxValue; + } + /** + * @return the intervalSize + */ + public int getIntervalSize() { + return intervalSize; + } + /** + * @param intervalSize the intervalSize to set + */ + public void setIntervalSize(int intervalSize) { + this.intervalSize = intervalSize; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/CohortVisitsDrilldown.java b/src/main/java/org/ohdsi/webapi/report/CohortVisitsDrilldown.java new file mode 100644 index 0000000000..cb636f823d --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CohortVisitsDrilldown.java @@ -0,0 +1,71 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +public class CohortVisitsDrilldown { + private List ageAtFirstOccurrence; + + private List visitDurationByType; + + private List prevalenceByGenderAgeYear; + + private List prevalenceByMonth; + + /** + * @return the ageAtFirstOccurrence + */ + public List getAgeAtFirstOccurrence() { + return ageAtFirstOccurrence; + } + + /** + * @param ageAtFirstOccurrence the ageAtFirstOccurrence to set + */ + public void setAgeAtFirstOccurrence( + List ageAtFirstOccurrence) { + this.ageAtFirstOccurrence = ageAtFirstOccurrence; + } + + /** + * @return the visitDurationByType + */ + public List getVisitDurationByType() { + return visitDurationByType; + } + + /** + * @param visitDurationByType the visitDurationByType to set + */ + public void setVisitDurationByType(List visitDurationByType) { + this.visitDurationByType = visitDurationByType; + } + + /** + * @return the prevalenceByGenderAgeYear + */ + public List getPrevalenceByGenderAgeYear() { + return prevalenceByGenderAgeYear; + } + + /** + * @param prevalenceByGenderAgeYear the prevalenceByGenderAgeYear to set + */ + public void setPrevalenceByGenderAgeYear( + List prevalenceByGenderAgeYear) { + this.prevalenceByGenderAgeYear = prevalenceByGenderAgeYear; + } + + /** + * @return the prevalenceByMonth + */ + public List getPrevalenceByMonth() { + return prevalenceByMonth; + } + + /** + * @param prevalenceByMonth the prevalenceByMonth to set + */ + public void setPrevalenceByMonth(List prevalenceByMonth) { + this.prevalenceByMonth = prevalenceByMonth; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/ConceptCountRecord.java b/src/main/java/org/ohdsi/webapi/report/ConceptCountRecord.java new file mode 100644 index 0000000000..1339c4f7b0 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/ConceptCountRecord.java @@ -0,0 +1,105 @@ +package org.ohdsi.webapi.report; + +/** + * + * i.e. donut + * + */ +public class ConceptCountRecord { + + private String conditionConceptName; + private long conditionConceptId; + + private String observationConceptName; + private long observationConceptId; + + private String conceptName; + private long conceptId; + + private long countValue; + + /** + * @return the conditionConceptName + */ + public String getConditionConceptName() { + return conditionConceptName; + } + /** + * @param conditionConceptName the conditionConceptName to set + */ + public void setConditionConceptName(String conditionConceptName) { + this.conditionConceptName = conditionConceptName; + } + /** + * @return the conditionConceptId + */ + public long getConditionConceptId() { + return conditionConceptId; + } + /** + * @param conditionConceptId the conditionConceptId to set + */ + public void setConditionConceptId(long conditionConceptId) { + this.conditionConceptId = conditionConceptId; + } + /** + * @return the observationConceptName + */ + public String getObservationConceptName() { + return observationConceptName; + } + /** + * @param observationConceptName the observationConceptName to set + */ + public void setObservationConceptName(String observationConceptName) { + this.observationConceptName = observationConceptName; + } + /** + * @return the observationConceptId + */ + public long getObservationConceptId() { + return observationConceptId; + } + /** + * @param observationConceptId the observationConceptId to set + */ + public void setObservationConceptId(long observationConceptId) { + this.observationConceptId = observationConceptId; + } + /** + * @return the conceptName + */ + public String getConceptName() { + return conceptName; + } + /** + * @param conceptName the conceptName to set + */ + public void setConceptName(String conceptName) { + this.conceptName = conceptName; + } + /** + * @return the conceptId + */ + public long getConceptId() { + return conceptId; + } + /** + * @param conceptId the conceptId to set + */ + public void setConceptId(long conceptId) { + this.conceptId = conceptId; + } + /** + * @return the countValue + */ + public long getCountValue() { + return countValue; + } + /** + * @param countValue the countValue to set + */ + public void setCountValue(long countValue) { + this.countValue = countValue; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/ConceptDecileRecord.java b/src/main/java/org/ohdsi/webapi/report/ConceptDecileRecord.java new file mode 100644 index 0000000000..2d4d20750c --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/ConceptDecileRecord.java @@ -0,0 +1,91 @@ +package org.ohdsi.webapi.report; + +/** + * + * i.e. Trellis plot record + * + */ +public class ConceptDecileRecord { + + private String trellisName; + private long conceptId; + private String seriesName; + private double yPrevalence1000Pp; + private int xCalendarYear; + private int numPersons; + + /** + * @return the numPersons + */ + public int getNumPersons() { + return numPersons; + } + /** + * @param numPersons the numPersons to set + */ + public void setNumPersons(int numPersons) { + this.numPersons = numPersons; + } + /** + * @return the trellisName + */ + public String getTrellisName() { + return trellisName; + } + /** + * @param trellisName the trellisName to set + */ + public void setTrellisName(String trellisName) { + this.trellisName = trellisName; + } + /** + * @return the conceptId + */ + public long getConceptId() { + return conceptId; + } + /** + * @param conceptId the conceptId to set + */ + public void setConceptId(long conceptId) { + this.conceptId = conceptId; + } + /** + * @return the seriesName + */ + public String getSeriesName() { + return seriesName; + } + /** + * @param seriesName the seriesName to set + */ + public void setSeriesName(String seriesName) { + this.seriesName = seriesName; + } + /** + * @return the yPrevalence1000Pp + */ + public double getyPrevalence1000Pp() { + return yPrevalence1000Pp; + } + /** + * @param yPrevalence1000Pp the yPrevalence1000Pp to set + */ + public void setyPrevalence1000Pp(double yPrevalence1000Pp) { + this.yPrevalence1000Pp = yPrevalence1000Pp; + } + /** + * @return the xCalendarYear + */ + public int getxCalendarYear() { + return xCalendarYear; + } + /** + * @param xCalendarYear the xCalendarYear to set + */ + public void setxCalendarYear(int xCalendarYear) { + this.xCalendarYear = xCalendarYear; + } + + +} diff --git a/src/main/java/org/ohdsi/webapi/report/ConceptDistributionRecord.java b/src/main/java/org/ohdsi/webapi/report/ConceptDistributionRecord.java new file mode 100644 index 0000000000..9b986e2a52 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/ConceptDistributionRecord.java @@ -0,0 +1,50 @@ +package org.ohdsi.webapi.report; + +/** + * + * i.e. histogram record + * + */ +public class ConceptDistributionRecord { + private int intervalIndex; + private double percentValue; + private long countValue; + /** + * @return the intervalIndex + */ + public int getIntervalIndex() { + return intervalIndex; + } + /** + * @param intervalIndex the intervalIndex to set + */ + public void setIntervalIndex(int intervalIndex) { + this.intervalIndex = intervalIndex; + } + /** + * @return the percentValue + */ + public double getPercentValue() { + return percentValue; + } + /** + * @param percentValue the percentValue to set + */ + public void setPercentValue(double percentValue) { + this.percentValue = percentValue; + } + /** + * @return the countValue + */ + public long getCountValue() { + return countValue; + } + /** + * @param countValue the countValue to set + */ + public void setCountValue(long countValue) { + this.countValue = countValue; + } + + +} diff --git a/src/main/java/org/ohdsi/webapi/report/ConceptQuartileRecord.java b/src/main/java/org/ohdsi/webapi/report/ConceptQuartileRecord.java new file mode 100644 index 0000000000..ad4d969993 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/ConceptQuartileRecord.java @@ -0,0 +1,131 @@ +package org.ohdsi.webapi.report; + +/** + * + * i.e. box plot + * + */ +public class ConceptQuartileRecord { + + private String category; + private long conceptId; + + private int p10Value; + private int p25Value; + private int p75Value; + private int p90Value; + + private int minValue; + private int medianValue; + private int maxValue; + + /** + * @return the category + */ + public String getCategory() { + return category; + } + /** + * @param category the category to set + */ + public void setCategory(String category) { + this.category = category; + } + /** + * @return the conceptId + */ + public long getConceptId() { + return conceptId; + } + /** + * @param conceptId the conceptId to set + */ + public void setConceptId(long conceptId) { + this.conceptId = conceptId; + } + /** + * @return the p10Value + */ + public int getP10Value() { + return p10Value; + } + /** + * @param p10Value the p10Value to set + */ + public void setP10Value(int p10Value) { + this.p10Value = p10Value; + } + /** + * @return the p25Value + */ + public int getP25Value() { + return p25Value; + } + /** + * @param p25Value the p25Value to set + */ + public void setP25Value(int p25Value) { + this.p25Value = p25Value; + } + /** + * @return the p75Value + */ + public int getP75Value() { + return p75Value; + } + /** + * @param p75Value the p75Value to set + */ + public void setP75Value(int p75Value) { + this.p75Value = p75Value; + } + /** + * @return the p90Value + */ + public int getP90Value() { + return p90Value; + } + /** + * @param p90Value the p90Value to set + */ + public void setP90Value(int p90Value) { + this.p90Value = p90Value; + } + /** + * @return the minValue + */ + public int getMinValue() { + return minValue; + } + /** + * @param minValue the minValue to set + */ + public void setMinValue(int minValue) { + this.minValue = minValue; + } + /** + * @return the medianValue + */ + public int getMedianValue() { + return medianValue; + } + /** + * @param medianValue the medianValue to set + */ + public void setMedianValue(int medianValue) { + this.medianValue = medianValue; + } + /** + * @return the maxValue + */ + public int getMaxValue() { + return maxValue; + } + /** + * @param maxValue the maxValue to set + */ + public void setMaxValue(int maxValue) { + this.maxValue = maxValue; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/CumulativeObservationRecord.java b/src/main/java/org/ohdsi/webapi/report/CumulativeObservationRecord.java new file mode 100644 index 0000000000..22bfa766c6 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CumulativeObservationRecord.java @@ -0,0 +1,45 @@ +package org.ohdsi.webapi.report; + +public class CumulativeObservationRecord { + + private String seriesName; + private int xLengthOfObservation; + private double yPercentPersons; + + /** + * @return the seriesName + */ + public String getSeriesName() { + return seriesName; + } + /** + * @param seriesName the seriesName to set + */ + public void setSeriesName(String seriesName) { + this.seriesName = seriesName; + } + /** + * @return the xLengthOfObservation + */ + public int getxLengthOfObservation() { + return xLengthOfObservation; + } + /** + * @param xLengthOfObservation the xLengthOfObservation to set + */ + public void setxLengthOfObservation(int xLengthOfObservation) { + this.xLengthOfObservation = xLengthOfObservation; + } + /** + * @return the yPercentPersons + */ + public double getyPercentPersons() { + return yPercentPersons; + } + /** + * @param yPercentPersons the yPercentPersons to set + */ + public void setyPercentPersons(double yPercentPersons) { + this.yPercentPersons = yPercentPersons; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/ExposureCohortResult.java b/src/main/java/org/ohdsi/webapi/report/ExposureCohortResult.java new file mode 100644 index 0000000000..f11f612c5f --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/ExposureCohortResult.java @@ -0,0 +1,35 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.ohdsi.webapi.report; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * + * @author asena5 + */ +public class ExposureCohortResult { + @JsonProperty("exposure_cohort_definition_id") + public String exposureCohortDefinitionId; + + @JsonProperty("outcome_cohort_definition_id") + public String outcomeCohortDefinitionId; + + @JsonProperty("num_persons_exposed") + public long numPersonsExposed; + + @JsonProperty("num_persons_w_outcome_pre_exposure") + public long numPersonsWithOutcomePreExposure; + + @JsonProperty("num_persons_w_outcome_post_exposure") + public long numPersonsWithOutcomePostExposure; + + @JsonProperty("time_at_risk") + public Float timeAtRisk; + + @JsonProperty("incidence_rate_1000py") + public Float incidenceRate1000py; +} diff --git a/src/main/java/org/ohdsi/webapi/report/ExposureCohortSearch.java b/src/main/java/org/ohdsi/webapi/report/ExposureCohortSearch.java new file mode 100644 index 0000000000..26702b2ff2 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/ExposureCohortSearch.java @@ -0,0 +1,26 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.ohdsi.webapi.report; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * + * @author asena5 + */ +public class ExposureCohortSearch { + + public ExposureCohortSearch(){} + + @JsonProperty("EXPOSURE_COHORT_LIST") + public String[] exposureCohortList; + + @JsonProperty("OUTCOME_COHORT_LIST") + public String[] outcomeCohortList; + + @JsonProperty("MIN_CELL_COUNT") + public int minCellCount = 0; +} diff --git a/src/main/java/org/ohdsi/webapi/report/HierarchicalConceptRecord.java b/src/main/java/org/ohdsi/webapi/report/HierarchicalConceptRecord.java new file mode 100644 index 0000000000..45d9406eb3 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/HierarchicalConceptRecord.java @@ -0,0 +1,167 @@ +package org.ohdsi.webapi.report; + +/** + * + * i.e. treemap + * + */ +public class HierarchicalConceptRecord { + + private long conceptId; + private String conceptPath; + private double recordsPerPerson; + private double percentPersons; + private long numPersons; + private double lengthOfEra; + private double percentPersonsBefore; + private double percentPersonsAfter; + private double riskDiffAfterBefore; + private double logRRAfterBefore; + private long countValue; + + public HierarchicalConceptRecord() { + // default constructor + } + + /** + * @return the conceptId + */ + public long getConceptId() { + return conceptId; + } + /** + * @param conceptId the conceptId to set + */ + public void setConceptId(long conceptId) { + this.conceptId = conceptId; + } + /** + * @return the conceptPath + */ + public String getConceptPath() { + return conceptPath; + } + /** + * @param conceptPath the conceptPath to set + */ + public void setConceptPath(String conceptPath) { + this.conceptPath = conceptPath; + } + /** + * @return the recordsPerPerson + */ + public double getRecordsPerPerson() { + return recordsPerPerson; + } + /** + * @param recordsPerPerson the recordsPerPerson to set + */ + public void setRecordsPerPerson(double recordsPerPerson) { + this.recordsPerPerson = recordsPerPerson; + } + /** + * @return the percentPersons + */ + public double getPercentPersons() { + return percentPersons; + } + /** + * @param percentPersons the percentPersons to set + */ + public void setPercentPersons(double percentPersons) { + this.percentPersons = percentPersons; + } + /** + * @return the numPersons + */ + public long getNumPersons() { + return numPersons; + } + /** + * @param numPersons the numPersons to set + */ + public void setNumPersons(long numPersons) { + this.numPersons = numPersons; + } + /** + * @return the lengthOfEra + */ + public double getLengthOfEra() { + return lengthOfEra; + } + /** + * @param lengthOfEra the lengthOfEra to set + */ + public void setLengthOfEra(double lengthOfEra) { + this.lengthOfEra = lengthOfEra; + } + /** + * @return the percentPersonsBefore + */ + public double getPercentPersonsBefore() { + return percentPersonsBefore; + } + + /** + * @param percentPersonsBefore the percentPersonsBefore to set + */ + public void setPercentPersonsBefore(double percentPersonsBefore) { + this.percentPersonsBefore = percentPersonsBefore; + } + + /** + * @return the percentPersonsAfter + */ + public double getPercentPersonsAfter() { + return percentPersonsAfter; + } + + /** + * @param percentPersonsAfter the percentPersonsAfter to set + */ + public void setPercentPersonsAfter(double percentPersonsAfter) { + this.percentPersonsAfter = percentPersonsAfter; + } + + /** + * @return the riskDiffAfterBefore + */ + public double getRiskDiffAfterBefore() { + return riskDiffAfterBefore; + } + + /** + * @param riskDiffAfterBefore the riskDiffAfterBefore to set + */ + public void setRiskDiffAfterBefore(double riskDiffAfterBefore) { + this.riskDiffAfterBefore = riskDiffAfterBefore; + } + + /** + * @return the logRRAfterBefore + */ + public double getLogRRAfterBefore() { + return logRRAfterBefore; + } + + /** + * @param logRRAfterBefore the logRRAfterBefore to set + */ + public void setLogRRAfterBefore(double logRRAfterBefore) { + this.logRRAfterBefore = logRRAfterBefore; + } + + /** + * @return the countValue + */ + public long getCountValue() { + return countValue; + } + /** + * @param countValue the countValue to set + */ + public void setCountValue(long countValue) { + this.countValue = countValue; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/MonthObservationRecord.java b/src/main/java/org/ohdsi/webapi/report/MonthObservationRecord.java new file mode 100644 index 0000000000..e3ad8dd150 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/MonthObservationRecord.java @@ -0,0 +1,45 @@ +package org.ohdsi.webapi.report; + +public class MonthObservationRecord { + + private int monthYear; + private double percentValue; + private long countValue; + + /** + * @return the monthYear + */ + public int getMonthYear() { + return monthYear; + } + /** + * @param monthYear the monthYear to set + */ + public void setMonthYear(int monthYear) { + this.monthYear = monthYear; + } + /** + * @return the percentValue + */ + public double getPercentValue() { + return percentValue; + } + /** + * @param percentValue the percentValue to set + */ + public void setPercentValue(double percentValue) { + this.percentValue = percentValue; + } + /** + * @return the countValue + */ + public long getCountValue() { + return countValue; + } + /** + * @param countValue the countValue to set + */ + public void setCountValue(long countValue) { + this.countValue = countValue; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/ObservationPeriodRecord.java b/src/main/java/org/ohdsi/webapi/report/ObservationPeriodRecord.java new file mode 100644 index 0000000000..84219d9ba0 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/ObservationPeriodRecord.java @@ -0,0 +1,58 @@ +package org.ohdsi.webapi.report; + +public class ObservationPeriodRecord { + private int cohortDefinitionId; + private double pctPersons; + private int countValue; + private int duration; + /** + * @return the cohortDefinitionId + */ + public int getCohortDefinitionId() { + return cohortDefinitionId; + } + /** + * @param cohortDefinitionId the cohortDefinitionId to set + */ + public void setCohortDefinitionId(int cohortDefinitionId) { + this.cohortDefinitionId = cohortDefinitionId; + } + /** + * @return the pctPersons + */ + public double getPctPersons() { + return pctPersons; + } + /** + * @param pctPersons the pctPersons to set + */ + public void setPctPersons(double pctPersons) { + this.pctPersons = pctPersons; + } + /** + * @return the countValue + */ + public int getCountValue() { + return countValue; + } + /** + * @param countValue the countValue to set + */ + public void setCountValue(int countValue) { + this.countValue = countValue; + } + /** + * @return the duration + */ + public int getDuration() { + return duration; + } + /** + * @param duration the duration to set + */ + public void setDuration(int duration) { + this.duration = duration; + } + + +} diff --git a/src/main/java/org/ohdsi/webapi/report/PredictorResult.java b/src/main/java/org/ohdsi/webapi/report/PredictorResult.java new file mode 100644 index 0000000000..51e1177f5e --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/PredictorResult.java @@ -0,0 +1,41 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.ohdsi.webapi.report; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * + * @author asena5 + */ +public class PredictorResult { + @JsonProperty("exposure_cohort_definition_id") + public String exposureCohortDefinitionId; + + @JsonProperty("outcome_cohort_definition_id") + public String outcomeCohortDefinitionId; + + @JsonProperty("concept_id") + public String conceptId; + + @JsonProperty("concept_name") + public String conceptName; + + @JsonProperty("domain_id") + public String domainId; + + @JsonProperty("concept_w_outcome") + public String conceptWithOutcome; + + @JsonProperty("pct_outcome_w_concept") + public String pctOutcomeWithConcept; + + @JsonProperty("pct_nooutcome_w_concept") + public String pctNoOutcomeWithConcept; + + @JsonProperty("abs_std_diff") + public String absStdDiff; +} diff --git a/src/main/java/org/ohdsi/webapi/report/PrevalenceRecord.java b/src/main/java/org/ohdsi/webapi/report/PrevalenceRecord.java new file mode 100644 index 0000000000..c68dd4c19f --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/PrevalenceRecord.java @@ -0,0 +1,72 @@ +package org.ohdsi.webapi.report; + +public class PrevalenceRecord { + + private int xCalendarMonth; + private long conceptId; + private String conceptName; + private double yPrevalence1000Pp; + private int numPersons; + + /** + * @return the xCalendarMonth + */ + public int getxCalendarMonth() { + return xCalendarMonth; + } + /** + * @param xCalendarMonth the xCalendarMonth to set + */ + public void setxCalendarMonth(int xCalendarMonth) { + this.xCalendarMonth = xCalendarMonth; + } + /** + * @return the conceptId + */ + public long getConceptId() { + return conceptId; + } + /** + * @param conceptId the conceptId to set + */ + public void setConceptId(long conceptId) { + this.conceptId = conceptId; + } + /** + * @return the conceptName + */ + public String getConceptName() { + return conceptName; + } + /** + * @param conceptName the conceptName to set + */ + public void setConceptName(String conceptName) { + this.conceptName = conceptName; + } + /** + * @return the yPrevalence1000Pp + */ + public double getyPrevalence1000Pp() { + return yPrevalence1000Pp; + } + /** + * @param yPrevalence1000Pp the yPrevalence1000Pp to set + */ + public void setyPrevalence1000Pp(double yPrevalence1000Pp) { + this.yPrevalence1000Pp = yPrevalence1000Pp; + } + /** + * @return the numPersons + */ + public int getNumPersons() { + return numPersons; + } + /** + * @param numPersons the numPersons to set + */ + public void setNumPersons(int numPersons) { + this.numPersons = numPersons; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/ScatterplotRecord.java b/src/main/java/org/ohdsi/webapi/report/ScatterplotRecord.java new file mode 100644 index 0000000000..8c9f388f62 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/ScatterplotRecord.java @@ -0,0 +1,84 @@ +package org.ohdsi.webapi.report; + +public class ScatterplotRecord { + + private String recordType; + private long conceptId; + private String conceptName; + private int duration; + private int countValue; + private double pctPersons; + + /** + * @return the recordType + */ + public String getRecordType() { + return recordType; + } + /** + * @param recordType the recordType to set + */ + public void setRecordType(String recordType) { + this.recordType = recordType; + } + /** + * @return the conceptId + */ + public long getConceptId() { + return conceptId; + } + /** + * @param conceptId the conceptId to set + */ + public void setConceptId(long conceptId) { + this.conceptId = conceptId; + } + /** + * @return the conceptName + */ + public String getConceptName() { + return conceptName; + } + /** + * @param conceptName the conceptName to set + */ + public void setConceptName(String conceptName) { + this.conceptName = conceptName; + } + /** + * @return the duration + */ + public int getDuration() { + return duration; + } + /** + * @param duration the duration to set + */ + public void setDuration(int duration) { + this.duration = duration; + } + /** + * @return the countValue + */ + public int getCountValue() { + return countValue; + } + /** + * @param countValue the countValue to set + */ + public void setCountValue(int countValue) { + this.countValue = countValue; + } + /** + * @return the pctPersons + */ + public double getPctPersons() { + return pctPersons; + } + /** + * @param pctPersons the pctPersons to set + */ + public void setPctPersons(double pctPersons) { + this.pctPersons = pctPersons; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/SeriesPerPerson.java b/src/main/java/org/ohdsi/webapi/report/SeriesPerPerson.java new file mode 100644 index 0000000000..b8b1b6a36e --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/SeriesPerPerson.java @@ -0,0 +1,43 @@ +package org.ohdsi.webapi.report; + +public class SeriesPerPerson { + private String seriesName; + private int xCalendarMonth; + private long yRecordCount; + /** + * @return the seriesName + */ + public String getSeriesName() { + return seriesName; + } + /** + * @param seriesName the seriesName to set + */ + public void setSeriesName(String seriesName) { + this.seriesName = seriesName; + } + /** + * @return the xCalendarMonth + */ + public int getxCalendarMonth() { + return xCalendarMonth; + } + /** + * @param xCalendarMonth the xCalendarMonth to set + */ + public void setxCalendarMonth(int xCalendarMonth) { + this.xCalendarMonth = xCalendarMonth; + } + /** + * @return the yRecordCount + */ + public long getyRecordCount() { + return yRecordCount; + } + /** + * @param yRecordCount the yRecordCount to set + */ + public void setyRecordCount(long yRecordCount) { + this.yRecordCount = yRecordCount; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/TimeToEventResult.java b/src/main/java/org/ohdsi/webapi/report/TimeToEventResult.java new file mode 100644 index 0000000000..41d43faddb --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/TimeToEventResult.java @@ -0,0 +1,32 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.ohdsi.webapi.report; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * + * @author asena5 + */ +public class TimeToEventResult { + @JsonProperty("exposure_cohort_definition_id") + public String exposureCohortDefinitionId; + + @JsonProperty("outcome_cohort_definition_id") + public String outcomeCohortDefinitionId; + + @JsonProperty("recordType") + public String recordType; + + @JsonProperty("duration") + public long duration; + + @JsonProperty("count_value") + public long countValue; + + @JsonProperty("pctPersons") + public double pctPersons; +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/CohortAttributeMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/CohortAttributeMapper.java new file mode 100644 index 0000000000..e19fe1f2d5 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/CohortAttributeMapper.java @@ -0,0 +1,19 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.CohortAttribute; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class CohortAttributeMapper implements RowMapper { + + @Override + public CohortAttribute mapRow(ResultSet rs, int rowNum) throws SQLException { + CohortAttribute attribute = new CohortAttribute(); + attribute.setAttributeName(rs.getString("ATTRIBUTE_NAME")); + attribute.setAttributeValue(rs.getString("ATTRIBUTE_VALUE")); + return attribute; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/CohortStatsMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/CohortStatsMapper.java new file mode 100644 index 0000000000..a46702660e --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/CohortStatsMapper.java @@ -0,0 +1,21 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.CohortStatsRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class CohortStatsMapper implements RowMapper { + + @Override + public CohortStatsRecord mapRow(ResultSet rs, int rowNum) + throws SQLException { + CohortStatsRecord stats = new CohortStatsRecord(); + stats.setIntervalSize(rs.getInt("INTERVAL_SIZE")); + stats.setMaxValue(rs.getInt("MAX_VALUE")); + stats.setMinValue(rs.getInt("MIN_VALUE")); + return stats; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptConditionCountMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptConditionCountMapper.java new file mode 100644 index 0000000000..ceed791d11 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptConditionCountMapper.java @@ -0,0 +1,23 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.ConceptCountRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ConceptConditionCountMapper implements RowMapper { + + @Override + public ConceptCountRecord mapRow(ResultSet rs, int rowNum) + throws SQLException { + ConceptCountRecord record = new ConceptCountRecord(); + record.setConditionConceptId(rs.getLong("CONDITION_CONCEPT_ID")); + record.setConceptId(rs.getLong("CONCEPT_ID")); + record.setConditionConceptName(rs.getString("CONDITION_CONCEPT_NAME")); + record.setConceptName(rs.getString("CONCEPT_NAME")); + record.setCountValue(rs.getLong("COUNT_VALUE")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptCountMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptCountMapper.java new file mode 100644 index 0000000000..e632dcf5b3 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptCountMapper.java @@ -0,0 +1,20 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.report.ConceptCountRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ConceptCountMapper implements RowMapper { + + @Override + public ConceptCountRecord mapRow(ResultSet rs, int rowNum) throws SQLException { + ConceptCountRecord record = new ConceptCountRecord(); + record.setConceptId(rs.getLong("CONCEPT_ID")); + record.setConceptName(rs.getString("CONCEPT_NAME")); + record.setCountValue(rs.getLong("COUNT_VALUE")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileCountsMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileCountsMapper.java new file mode 100644 index 0000000000..b78e75dd76 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileCountsMapper.java @@ -0,0 +1,22 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.ConceptDecileRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ConceptDecileCountsMapper implements RowMapper { + + @Override + public ConceptDecileRecord mapRow(ResultSet rs, int rowNum) throws SQLException { + ConceptDecileRecord record = new ConceptDecileRecord(); + record.setTrellisName(rs.getString("TRELLIS_NAME")); + record.setSeriesName(rs.getString("SERIES_NAME")); + record.setyPrevalence1000Pp(rs.getDouble("Y_PREVALENCE_1000PP")); + record.setxCalendarYear(rs.getInt("X_CALENDAR_YEAR")); + record.setNumPersons(rs.getInt("NUM_PERSONS")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileMapper.java new file mode 100644 index 0000000000..192f27a8df --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileMapper.java @@ -0,0 +1,22 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.ConceptDecileRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ConceptDecileMapper implements RowMapper { + + @Override + public ConceptDecileRecord mapRow(ResultSet rs, int rowNum) throws SQLException { + ConceptDecileRecord record = new ConceptDecileRecord(); + record.setTrellisName(rs.getString("TRELLIS_NAME")); + record.setConceptId(rs.getLong("CONCEPT_ID")); + record.setSeriesName(rs.getString("SERIES_NAME")); + record.setyPrevalence1000Pp(rs.getDouble("Y_PREVALENCE_1000PP")); + record.setxCalendarYear(rs.getInt("X_CALENDAR_YEAR")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDistributionMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDistributionMapper.java new file mode 100644 index 0000000000..7397534b14 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDistributionMapper.java @@ -0,0 +1,21 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.report.ConceptDistributionRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ConceptDistributionMapper implements RowMapper{ + + @Override + public ConceptDistributionRecord mapRow(ResultSet rs, int rowNum) + throws SQLException { + ConceptDistributionRecord record = new ConceptDistributionRecord(); + record.setCountValue(rs.getLong("COUNT_VALUE")); + record.setIntervalIndex(rs.getInt("INTERVAL_INDEX")); + record.setPercentValue(rs.getDouble("PERCENT_VALUE")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptObservationCountMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptObservationCountMapper.java new file mode 100644 index 0000000000..ea5eb755f1 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptObservationCountMapper.java @@ -0,0 +1,23 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.ConceptCountRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ConceptObservationCountMapper implements RowMapper { + + @Override + public ConceptCountRecord mapRow(ResultSet rs, int rowNum) + throws SQLException { + ConceptCountRecord record = new ConceptCountRecord(); + record.setObservationConceptId(rs.getLong("OBSERVATION_CONCEPT_ID")); + record.setConceptId(rs.getLong("CONCEPT_ID")); + record.setObservationConceptName(rs.getString("OBSERVATION_CONCEPT_ID")); + record.setConceptName(rs.getString("CONCEPT_NAME")); + record.setCountValue(rs.getLong("COUNT_VALUE")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptQuartileMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptQuartileMapper.java new file mode 100644 index 0000000000..6e2f636332 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptQuartileMapper.java @@ -0,0 +1,26 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.ConceptQuartileRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ConceptQuartileMapper implements RowMapper { + + @Override + public ConceptQuartileRecord mapRow(ResultSet rs, int rowNum) throws SQLException { + ConceptQuartileRecord record = new ConceptQuartileRecord(); + record.setCategory(rs.getString("CATEGORY")); + record.setConceptId(rs.getLong("CONCEPT_ID")); + record.setMaxValue(rs.getInt("MAX_VALUE")); + record.setP75Value(rs.getInt("P75_VALUE")); + record.setP10Value(rs.getInt("P10_VALUE")); + record.setMedianValue(rs.getInt("MEDIAN_VALUE")); + record.setP25Value(rs.getInt("P25_VALUE")); + record.setMinValue(rs.getInt("MIN_VALUE")); + record.setP90Value(rs.getInt("P90_VALUE")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/CumulativeObservationMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/CumulativeObservationMapper.java new file mode 100644 index 0000000000..ba304ac628 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/CumulativeObservationMapper.java @@ -0,0 +1,20 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.report.CumulativeObservationRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class CumulativeObservationMapper implements RowMapper { + + @Override + public CumulativeObservationRecord mapRow(ResultSet rs, int rowNum) throws SQLException { + CumulativeObservationRecord record = new CumulativeObservationRecord(); + record.setSeriesName(rs.getString("SERIES_NAME")); + record.setxLengthOfObservation(rs.getInt("X_LENGTH_OF_OBSERVATION")); + record.setyPercentPersons(rs.getDouble("Y_PERCENT_PERSONS")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/HierarchicalConceptEraMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/HierarchicalConceptEraMapper.java new file mode 100644 index 0000000000..b5c9367ec6 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/HierarchicalConceptEraMapper.java @@ -0,0 +1,22 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.HierarchicalConceptRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class HierarchicalConceptEraMapper implements RowMapper { + + @Override + public HierarchicalConceptRecord mapRow(ResultSet rs, int rowNum) throws SQLException { + HierarchicalConceptRecord record = new HierarchicalConceptRecord(); + record.setConceptId(rs.getLong("CONCEPT_ID")); + record.setLengthOfEra(rs.getDouble("LENGTH_OF_ERA")); + record.setConceptPath(rs.getString("CONCEPT_PATH")); + record.setNumPersons(rs.getLong("NUM_PERSONS")); + record.setPercentPersons(rs.getDouble("PERCENT_PERSONS")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/HierarchicalConceptMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/HierarchicalConceptMapper.java new file mode 100644 index 0000000000..71e724699d --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/HierarchicalConceptMapper.java @@ -0,0 +1,22 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.HierarchicalConceptRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class HierarchicalConceptMapper implements RowMapper { + + @Override + public HierarchicalConceptRecord mapRow(ResultSet rs, int rowNum) throws SQLException { + HierarchicalConceptRecord record = new HierarchicalConceptRecord(); + record.setConceptId(rs.getLong("CONCEPT_ID")); + record.setConceptPath(rs.getString("CONCEPT_PATH")); + record.setRecordsPerPerson(rs.getDouble("RECORDS_PER_PERSON")); + record.setNumPersons(rs.getLong("NUM_PERSONS")); + record.setPercentPersons(rs.getDouble("PERCENT_PERSONS")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/HierarchicalConceptPrevalenceMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/HierarchicalConceptPrevalenceMapper.java new file mode 100644 index 0000000000..da80078825 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/HierarchicalConceptPrevalenceMapper.java @@ -0,0 +1,26 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.HierarchicalConceptRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class HierarchicalConceptPrevalenceMapper implements RowMapper { + + @Override + public HierarchicalConceptRecord mapRow(ResultSet rs, int rowNum) throws SQLException { + HierarchicalConceptRecord record = new HierarchicalConceptRecord(); + record.setConceptId(rs.getLong("CONCEPT_ID")); + record.setConceptPath(rs.getString("CONCEPT_PATH")); + record.setNumPersons(rs.getLong("NUM_PERSONS")); + record.setPercentPersons(rs.getDouble("PERCENT_PERSONS")); + record.setPercentPersonsBefore(rs.getDouble("PERCENT_PERSONS_BEFORE")); + record.setPercentPersonsAfter(rs.getDouble("PERCENT_PERSONS_AFTER")); + record.setRiskDiffAfterBefore(rs.getDouble("RISK_DIFF_AFTER_BEFORE")); + record.setLogRRAfterBefore(rs.getDouble("LOGRR_AFTER_BEFORE")); + record.setCountValue(rs.getLong("COUNT_VALUE")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/MonthObservationMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/MonthObservationMapper.java new file mode 100644 index 0000000000..ee44695591 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/MonthObservationMapper.java @@ -0,0 +1,20 @@ + package org.ohdsi.webapi.report.mapper; + + import org.ohdsi.webapi.report.MonthObservationRecord; + import org.springframework.jdbc.core.RowMapper; + + import java.sql.ResultSet; + import java.sql.SQLException; + + public class MonthObservationMapper implements RowMapper { + + @Override + public MonthObservationRecord mapRow(ResultSet rs, int rowNum) throws SQLException { + MonthObservationRecord record = new MonthObservationRecord(); + record.setMonthYear(rs.getInt("MONTH_YEAR")); + record.setPercentValue(rs.getDouble("PERCENT_VALUE")); + record.setCountValue(rs.getLong("COUNT_VALUE")); + return record; + } + + } diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ObservationPeriodMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ObservationPeriodMapper.java new file mode 100644 index 0000000000..a7b1f1e1b4 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ObservationPeriodMapper.java @@ -0,0 +1,22 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.ObservationPeriodRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ObservationPeriodMapper implements RowMapper { + + @Override + public ObservationPeriodRecord mapRow(ResultSet rs, int rowNum) + throws SQLException { + ObservationPeriodRecord obsRecord = new ObservationPeriodRecord(); + obsRecord.setCohortDefinitionId(rs.getInt("COHORT_DEFINITION_ID")); + obsRecord.setPctPersons(rs.getDouble("PCT_PERSONS")); + obsRecord.setCountValue(rs.getInt("COUNT_VALUE")); + obsRecord.setDuration(rs.getInt("DURATION")); + return obsRecord; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceConceptMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceConceptMapper.java new file mode 100644 index 0000000000..cca4d2e000 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceConceptMapper.java @@ -0,0 +1,21 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.PrevalenceRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class PrevalanceConceptMapper implements RowMapper { + + @Override + public PrevalenceRecord mapRow(ResultSet rs, int rowNum) + throws SQLException { + PrevalenceRecord record = new PrevalenceRecord(); + record.setyPrevalence1000Pp(rs.getDouble("Y_PREVALENCE_1000PP")); + record.setxCalendarMonth(rs.getInt("X_CALENDAR_MONTH")); + record.setConceptId(rs.getLong("CONCEPT_ID")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceConceptNameMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceConceptNameMapper.java new file mode 100644 index 0000000000..ddfb5c1562 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceConceptNameMapper.java @@ -0,0 +1,22 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.PrevalenceRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class PrevalanceConceptNameMapper implements RowMapper { + + @Override + public PrevalenceRecord mapRow(ResultSet rs, int rowNum) + throws SQLException { + PrevalenceRecord record = new PrevalenceRecord(); + record.setyPrevalence1000Pp(rs.getDouble("Y_PREVALENCE_1000PP")); + record.setxCalendarMonth(rs.getInt("X_CALENDAR_MONTH")); + record.setConceptId(rs.getLong("CONCEPT_ID")); + record.setConceptName(rs.getString("CONCEPT_NAME")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceMapper.java new file mode 100644 index 0000000000..cc186447c5 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceMapper.java @@ -0,0 +1,21 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.PrevalenceRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class PrevalanceMapper implements RowMapper { + + @Override + public PrevalenceRecord mapRow(ResultSet rs, int rowNum) + throws SQLException { + PrevalenceRecord record = new PrevalenceRecord(); + record.setyPrevalence1000Pp(rs.getDouble("Y_PREVALENCE_1000PP")); + record.setxCalendarMonth(rs.getInt("X_CALENDAR_MONTH")); + record.setNumPersons(rs.getInt("NUM_PERSONS")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ScatterplotMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ScatterplotMapper.java new file mode 100644 index 0000000000..20758a0277 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ScatterplotMapper.java @@ -0,0 +1,24 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.ScatterplotRecord; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class ScatterplotMapper implements RowMapper { + + @Override + public ScatterplotRecord mapRow(ResultSet rs, int rowNum) + throws SQLException { + ScatterplotRecord record = new ScatterplotRecord(); + record.setRecordType(rs.getString("RECORD_TYPE")); + record.setConceptId(rs.getLong("CONCEPT_ID")); + record.setConceptName(rs.getString("CONCEPT_NAME")); + record.setCountValue(rs.getInt("COUNT_VALUE")); + record.setDuration(rs.getInt("DURATION")); + record.setPctPersons(rs.getDouble("PCT_PERSONS")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/SeriesPerPersonMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/SeriesPerPersonMapper.java new file mode 100644 index 0000000000..75643b0c47 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/mapper/SeriesPerPersonMapper.java @@ -0,0 +1,21 @@ +package org.ohdsi.webapi.report.mapper; + +import org.ohdsi.webapi.cohortresults.SeriesPerPerson; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public class SeriesPerPersonMapper implements RowMapper { + + @Override + public SeriesPerPerson mapRow(ResultSet rs, int rowNum) + throws SQLException { + SeriesPerPerson record = new SeriesPerPerson(); + record.setSeriesName(rs.getString("SERIES_NAME")); + record.setxCalendarMonth(rs.getInt("X_CALENDAR_MONTH")); + record.setyRecordCount(rs.getInt("Y_RECORD_COUNT")); + return record; + } + +} diff --git a/src/main/java/org/ohdsi/webapi/report/package-info.java b/src/main/java/org/ohdsi/webapi/report/package-info.java new file mode 100644 index 0000000000..36a01bf743 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/package-info.java @@ -0,0 +1,4 @@ +/** + * Model specific classes used by for viewing Achilles results (cohort results) + */ +package org.ohdsi.webapi.report; \ No newline at end of file diff --git a/src/main/java/org/ohdsi/webapi/service/CDMResultsService.java b/src/main/java/org/ohdsi/webapi/service/CDMResultsService.java index d3233e88c6..de51d666f0 100644 --- a/src/main/java/org/ohdsi/webapi/service/CDMResultsService.java +++ b/src/main/java/org/ohdsi/webapi/service/CDMResultsService.java @@ -2,193 +2,755 @@ import java.sql.ResultSet; import java.sql.SQLException; +import java.util.*; import java.util.AbstractMap.SimpleEntry; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; +import javax.annotation.PostConstruct; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; + +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.lang3.StringUtils; import org.ohdsi.sql.SqlRender; import org.ohdsi.sql.SqlTranslate; +import org.ohdsi.webapi.report.*; +import org.ohdsi.webapi.report.mapper.*; +//import org.ohdsi.webapi.cohortresults.VisualizationData; import org.ohdsi.webapi.helper.ResourceHelper; -import org.ohdsi.webapi.report.ConditionOccurrenceTreemapNode; -import org.ohdsi.webapi.report.DrugPrevalence; -import org.ohdsi.webapi.report.DrugEraPrevalence; -import org.ohdsi.webapi.report.MonthlyPrevalence; import org.ohdsi.webapi.source.Source; import org.ohdsi.webapi.source.SourceDaimon; import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.ResultSetExtractor; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Component; /** - * * @author fdefalco */ @Path("{sourceKey}/cdmresults/") @Component public class CDMResultsService extends AbstractDaoService { - @Path("{conceptId}/monthlyConditionOccurrencePrevalence") - @GET - @Produces(MediaType.APPLICATION_JSON) - public MonthlyPrevalence getMonthlyConditionOccurrencePrevalence(@PathParam("sourceKey") String sourceKey, @PathParam("conceptId") String conceptId) { - try { - Source source = getSourceRepository().findBySourceKey(sourceKey); - String tableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); + private ObjectMapper mapper = new ObjectMapper(); + private CDMResultsAnalysisRunner queryRunner = null; + + @PostConstruct + public void init() { + queryRunner = new CDMResultsAnalysisRunner(this.getSourceDialect()/*, this.visualizationDataRepository*/); + } + + @Path("{conceptId}/monthlyConditionOccurrencePrevalence") + @GET + @Produces(MediaType.APPLICATION_JSON) + public MonthlyPrevalence getMonthlyConditionOccurrencePrevalence(@PathParam("sourceKey") String sourceKey, @PathParam("conceptId") String conceptId) { + try { + Source source = getSourceRepository().findBySourceKey(sourceKey); + String tableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); + + String sql_statement = ResourceHelper.GetResourceAsString("/resources/cdmresults/sql/getMonthlyConditionOccurrencePrevalence.sql"); + sql_statement = SqlRender.renderSql(sql_statement, new String[]{"OHDSI_schema", "conceptId"}, new String[]{tableQualifier, conceptId}); + sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect()); - String sql_statement = ResourceHelper.GetResourceAsString("/resources/cdmresults/sql/getMonthlyConditionOccurrencePrevalence.sql"); - sql_statement = SqlRender.renderSql(sql_statement, new String[]{"OHDSI_schema", "conceptId"}, new String[]{tableQualifier, conceptId}); - sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect()); + return getSourceJdbcTemplate(source).query(sql_statement, new ResultSetExtractor() { + @Override + public MonthlyPrevalence extractData(ResultSet rs) throws SQLException, DataAccessException { + MonthlyPrevalence result = new MonthlyPrevalence(); + while (rs.next()) { + result.monthKey.add(rs.getString(1)); + result.prevalence.add(rs.getFloat(2)); + } + return result; + } + }); + } catch (Exception exception) { + throw new RuntimeException("Error retrieving monthly condition occurrence prevalence statistics." + exception.getMessage()); + } + } - return getSourceJdbcTemplate(source).query(sql_statement, new ResultSetExtractor() { + private final RowMapper> rowMapper = new RowMapper>() { @Override - public MonthlyPrevalence extractData(ResultSet rs) throws SQLException, DataAccessException { - MonthlyPrevalence result = new MonthlyPrevalence(); - while (rs.next()) { - result.monthKey.add(rs.getString(1)); - result.prevalence.add(rs.getFloat(2)); - } - return result; - } - }); - } catch (Exception exception) { - throw new RuntimeException("Error retrieving monthly condition occurrence prevalence statistics." + exception.getMessage()); - } - } - - private final RowMapper> rowMapper = new RowMapper>() { - @Override - public SimpleEntry mapRow(final ResultSet resultSet, final int arg1) throws SQLException { - long id = resultSet.getLong("concept_id"); - long record_count = resultSet.getLong("record_count"); - long descendant_record_count = resultSet.getLong("descendant_record_count"); - - SimpleEntry entry = new SimpleEntry(id, new Long[] { record_count, descendant_record_count }); - return entry; - } - }; - - @Path("conceptRecordCount") - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - public List> getConceptRecordCount(@PathParam("sourceKey") String sourceKey, String[] identifiers) { - Source source = getSourceRepository().findBySourceKey(sourceKey); - String resultTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); - String vocabularyTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Vocabulary); - - for (int i = 0; i < identifiers.length; i++) { - identifiers[i] = "'" + identifiers[i] + "'"; - } - - String identifierList = StringUtils.join(identifiers, ","); - String sql_statement = ResourceHelper.GetResourceAsString("/resources/cdmresults/sql/getConceptRecordCount.sql"); - sql_statement = SqlRender.renderSql(sql_statement, new String[]{"resultTableQualifier", "vocabularyTableQualifier", "conceptIdentifiers"}, new String[]{resultTableQualifier, vocabularyTableQualifier, identifierList}); - sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect()); - - return getSourceJdbcTemplate(source).query(sql_statement, rowMapper); - } - @Path("drugeratreemap") - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - public List getDrugEraTreemap(@PathParam("sourceKey") String sourceKey, String[] identifiers) { - Source source = getSourceRepository().findBySourceKey(sourceKey); - String tableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); - String vocabularyTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Vocabulary); - - for (int i = 0; i < identifiers.length; i++) { - identifiers[i] = "'" + identifiers[i] + "'"; - } - - String identifierList = StringUtils.join(identifiers, ","); - String sql_statement = ResourceHelper.GetResourceAsString("/resources/cdmresults/sql/getDrugEraTreemap.sql"); - sql_statement = SqlRender.renderSql(sql_statement, new String[]{"ohdsi_database_schema", "vocabulary_database_schema", "conceptList"}, new String[]{tableQualifier, vocabularyTableQualifier, identifierList}); - sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect()); - - - List> rows = getSourceJdbcTemplate(source).queryForList(sql_statement); - List listOfResults = new ArrayList(); - for (Map rs : rows) { - DrugPrevalence d = new DrugPrevalence(); - d.conceptId = Long.valueOf(String.valueOf(rs.get("concept_id"))); - d.conceptPath = String.valueOf(rs.get("concept_path")); - d.lengthOfEra = Float.valueOf(String.valueOf(rs.get("length_of_era"))); - d.numPersons = Long.valueOf(String.valueOf(rs.get("num_persons"))); - d.percentPersons = Float.valueOf(String.valueOf(rs.get("percent_persons"))); - listOfResults.add(d); - } - - return listOfResults; - } - - @Path("{conceptId}/drugeraprevalence") - @GET - @Produces(MediaType.APPLICATION_JSON) - public List getDrugEraPrevalenceByGenderAgeYear(@PathParam("sourceKey") String sourceKey, @PathParam("conceptId") String conceptId) { - Source source = getSourceRepository().findBySourceKey(sourceKey); - String tableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); - String vocabularyTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Vocabulary); - - String sql_statement = ResourceHelper.GetResourceAsString("/resources/cdmresults/sql/getDrugEraPrevalenceByGenderAgeYear.sql"); - sql_statement = SqlRender.renderSql(sql_statement, new String[]{"ohdsi_database_schema", "vocabulary_database_schema", "conceptId"}, new String[]{tableQualifier, vocabularyTableQualifier, conceptId}); - sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect()); - - - List> rows = getSourceJdbcTemplate(source).queryForList(sql_statement); - List listOfResults = new ArrayList(); - for (Map rs : rows) { - DrugEraPrevalence d = new DrugEraPrevalence(); - d.conceptId = Long.valueOf(String.valueOf(rs.get("concept_id"))); - d.trellisName = String.valueOf(rs.get("trellis_name")); - d.seriesName = String.valueOf(rs.get("series_name")); - d.xCalendarYear = Long.valueOf(String.valueOf(rs.get("x_calendar_year"))); - d.yPrevalence1000Pp = Float.valueOf(String.valueOf(rs.get("y_prevalence_1000pp"))); - listOfResults.add(d); - } - - return listOfResults; - } - - @Path("conditionoccurrencetreemap") - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - public List getConditionOccurrenceTreemap(@PathParam("sourceKey") String sourceKey, String[] identifiers) { - Source source = getSourceRepository().findBySourceKey(sourceKey); - String tableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); - String cdmTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.CDM); - - for (int i = 0; i < identifiers.length; i++) { - identifiers[i] = "'" + identifiers[i] + "'"; - } - - String identifierList = StringUtils.join(identifiers, ","); - String sql_statement = ResourceHelper.GetResourceAsString("/resources/cdmresults/sql/getConditionOccurrenceTreemap.sql"); - sql_statement = SqlRender.renderSql(sql_statement, new String[]{"ohdsi_database_schema", "cdm_database_schema", "conceptIdList"}, new String[]{tableQualifier, cdmTableQualifier, identifierList}); - sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect()); - - - List> rows = getSourceJdbcTemplate(source).queryForList(sql_statement); - List listOfResults = new ArrayList(); - for (Map rs : rows) { - ConditionOccurrenceTreemapNode c = new ConditionOccurrenceTreemapNode(); - c.conceptId = Long.valueOf(String.valueOf(rs.get("concept_id"))); - c.conceptPath = String.valueOf(rs.get("concept_path")); - c.numPersons = Long.valueOf(String.valueOf(rs.get("num_persons"))); - c.percentPersons = Float.valueOf(String.valueOf(rs.get("percent_persons"))); - c.recordsPerPerson = Float.valueOf(String.valueOf(rs.get("records_per_person"))); - listOfResults.add(c); - } - - return listOfResults; - } + public SimpleEntry mapRow(final ResultSet resultSet, final int arg1) throws SQLException { + long id = resultSet.getLong("concept_id"); + long record_count = resultSet.getLong("record_count"); + long descendant_record_count = resultSet.getLong("descendant_record_count"); + + SimpleEntry entry = new SimpleEntry(id, new Long[]{record_count, descendant_record_count}); + return entry; + } + }; + + @Path("conceptRecordCount") + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public List> getConceptRecordCount(@PathParam("sourceKey") String sourceKey, String[] identifiers) { + Source source = getSourceRepository().findBySourceKey(sourceKey); + String resultTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); + String vocabularyTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Vocabulary); + + for (int i = 0; i < identifiers.length; i++) { + identifiers[i] = "'" + identifiers[i] + "'"; + } + + String identifierList = StringUtils.join(identifiers, ","); + String sql_statement = ResourceHelper.GetResourceAsString("/resources/cdmresults/sql/getConceptRecordCount.sql"); + sql_statement = SqlRender.renderSql(sql_statement, new String[]{"resultTableQualifier", "vocabularyTableQualifier", "conceptIdentifiers"}, new String[]{resultTableQualifier, vocabularyTableQualifier, identifierList}); + sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect()); + + return getSourceJdbcTemplate(source).query(sql_statement, rowMapper); + } + + /** + * Queries for CDM dashboard for the given sourceKey + * + * @return CDMDashboard + */ + @GET + @Path("dashboard") + @Produces(MediaType.APPLICATION_JSON) + public CDMDashboard getDashboard(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { + + final String key = CDMResultsAnalysisRunner.DASHBOARD; + Source source = getSourceRepository().findBySourceKey(sourceKey); +// AchillesVisualizationData data = /*refresh ?*/ null /* : this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(id, source.getSourceId(), key)*/; + + CDMDashboard dashboard = null; + + if (refresh /*|| data == null*/) { + dashboard = queryRunner.getDashboard(getSourceJdbcTemplate(source), /*id,*/ source, /*demographicsOnly,*/ true); + } else { + try { +// dashboard = mapper.readValue(data.getData(), CDMDashboard.class); + } catch (Exception e) { + log.error(e); + } + } + + return dashboard; + + } + + /** + * Queries for person report results for the given sourceKey + * + * @return CDMPersonSummary + */ + @GET + @Path("person") + @Produces(MediaType.APPLICATION_JSON) + public CDMPersonSummary getPersonReport(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { + CDMPersonSummary person = null; + final String key = CDMResultsAnalysisRunner.PERSON; + Source source = getSourceRepository().findBySourceKey(sourceKey); +// AchillesVisualizationData data = /* refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; + + if (refresh /*|| data == null*/) { + person = this.queryRunner.getPersonResults(this.getSourceJdbcTemplate(source), source, true); + } else { + try { +// person = mapper.readValue(data.getData(), CDMPersonSummary.class); + } catch (Exception e) { + log.error(e); + } + } + + return person; + } + + /** + * Queries for drug report results for the given sourceKey + * + * @return CDMDrugSummary + */ + @GET + @Path("drug") + @Produces(MediaType.APPLICATION_JSON) + public CDMDrugSummary getDrugReport(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { + CDMDrugSummary drugSummary = null; + final String key = CDMResultsAnalysisRunner.DRUG; + Source source = getSourceRepository().findBySourceKey(sourceKey); +// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; + + if (refresh /*|| data == null*/) { + drugSummary = this.queryRunner.getDrugResults(this.getSourceJdbcTemplate(source), source, true); + } else { + try { +// drugSummary = mapper.readValue(data.getData(), CDMDrugSummary.class); + } catch (Exception e) { + log.error(e); + } + } + + return drugSummary; + } + + /** + * Queries for person report results for the given sourceKey + * + * @return CDMProcedureSummary + */ + @GET + @Path("procedure") + @Produces(MediaType.APPLICATION_JSON) + public CDMProcedureSummary getProcedureReport(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { + CDMProcedureSummary procedureSummary = null; + final String key = CDMResultsAnalysisRunner.PROCEDURE; + Source source = getSourceRepository().findBySourceKey(sourceKey); +// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; + + if (refresh /*|| data == null*/) { + procedureSummary = this.queryRunner.getProcedureResults(this.getSourceJdbcTemplate(source), source, true); + } else { + try { +// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); + } catch (Exception e) { + log.error(e); + } + } + + return procedureSummary; + } + + /** + * Queries for achilles heel report for the given sourceKey + * + * @return CDMAchillesHeel + */ + @GET + @Path("achillesheel") + @Produces(MediaType.APPLICATION_JSON) + public CDMAchillesHeel getAchillesHeelReport(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { + CDMAchillesHeel cdmAchillesHeel = null; + final String key = CDMResultsAnalysisRunner.HEEL; + Source source = getSourceRepository().findBySourceKey(sourceKey); +// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; + + if (refresh /*|| data == null*/) { + cdmAchillesHeel = this.queryRunner.getHeelResults(this.getSourceJdbcTemplate(source), source, true); + } else { + try { +// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); + } catch (Exception e) { + log.error(e); + } + } + + return cdmAchillesHeel; + } + + /** + * Queries for observation period report for the given sourceKey + * + * @return CDMObservationPeriod + */ + @GET + @Path("observationperiod") + @Produces(MediaType.APPLICATION_JSON) + public CDMObservationPeriod getObservationPeriods(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { + CDMObservationPeriod cdmObservationPeriod = null; + final String key = CDMResultsAnalysisRunner.OBSERVATIONPERIOD; + Source source = getSourceRepository().findBySourceKey(sourceKey); +// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; + + if (refresh /*|| data == null*/) { + cdmObservationPeriod = this.queryRunner.getObservationPeriodResults(this.getSourceJdbcTemplate(source), source, true); + } else { + try { +// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); + } catch (Exception e) { + log.error(e); + } + } + + return cdmObservationPeriod; + } + + /** + * Queries for observations report for the given sourceKey + * + * @return CDMObservation + */ + @GET + @Path("observation") + @Produces(MediaType.APPLICATION_JSON) + public List getObservations(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { + List cdmObservationPeriods = null; + final String key = CDMResultsAnalysisRunner.OBSERVATION; + Source source = getSourceRepository().findBySourceKey(sourceKey); +// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; + + if (refresh /*|| data == null*/) { + cdmObservationPeriods = this.queryRunner.getObservationResults(this.getSourceJdbcTemplate(source), source, true); + } else { + try { +// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); + } catch (Exception e) { + log.error(e); + } + } + + return cdmObservationPeriods; + } + + /** + * Queries for data density report for the given sourceKey + * + * @return CDMDataDensity + */ + @GET + @Path("datadensity") + @Produces(MediaType.APPLICATION_JSON) + public CDMDataDensity getDataDensity(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { + CDMDataDensity cdmDataDensity = null; + final String key = CDMResultsAnalysisRunner.DATADENSITY; + Source source = getSourceRepository().findBySourceKey(sourceKey); +// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; + + if (refresh /*|| data == null*/) { + cdmDataDensity = this.queryRunner.getDataDensityResults(this.getSourceJdbcTemplate(source), source, true); + } else { + try { +// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); + } catch (Exception e) { + log.error(e); + } + } + + return cdmDataDensity; + } + + /** + * Queries for condition report for the given sourceKey + * + * @return CDMConditionTree + */ + @GET + @Path("condition_treemap") + @Produces(MediaType.APPLICATION_JSON) + public List getConditionTreeMap(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { + List cdmConditions = null; + final String key = CDMResultsAnalysisRunner.CONDITION; + Source source = getSourceRepository().findBySourceKey(sourceKey); +// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; + + if (refresh /*|| data == null*/) { + cdmConditions = this.queryRunner.getCondition(this.getSourceJdbcTemplate(source), source, true); + } else { + try { +// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); + } catch (Exception e) { + log.error(e); + } + } + + return cdmConditions; + } + + /** + * Queries for condition era report for the given sourceKey + * + * @return CDMConditionEra + */ + @GET + @Path("conditionera_treemap") + @Produces(MediaType.APPLICATION_JSON) + public List getConditionEraTreeMap(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { + List cdmConditionEras = null; + final String key = CDMResultsAnalysisRunner.CONDITIONERA; + Source source = getSourceRepository().findBySourceKey(sourceKey); +// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; + + if (refresh /*|| data == null*/) { + cdmConditionEras = this.queryRunner.getConditionEras(this.getSourceJdbcTemplate(source), source, true); + } else { + try { +// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); + } catch (Exception e) { + log.error(e); + } + } + + return cdmConditionEras; + } + + + @Path("drugeratreemap") + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public List getDrugEraTreemap(@PathParam("sourceKey") String sourceKey, String[] identifiers) { + Source source = getSourceRepository().findBySourceKey(sourceKey); + String tableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); + String vocabularyTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Vocabulary); + + for (int i = 0; i < identifiers.length; i++) { + identifiers[i] = "'" + identifiers[i] + "'"; + } + + String identifierList = StringUtils.join(identifiers, ","); + String sql_statement = ResourceHelper.GetResourceAsString("/resources/cdmresults/sql/getDrugEraTreemap.sql"); + sql_statement = SqlRender.renderSql(sql_statement, new String[]{"ohdsi_database_schema", "vocabulary_database_schema", "conceptList"}, new String[]{tableQualifier, vocabularyTableQualifier, identifierList}); + sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect()); + + + List> rows = getSourceJdbcTemplate(source).queryForList(sql_statement); + List listOfResults = new ArrayList(); + for (Map rs : rows) { + DrugPrevalence d = new DrugPrevalence(); + d.conceptId = Long.valueOf(String.valueOf(rs.get("concept_id"))); + d.conceptPath = String.valueOf(rs.get("concept_path")); + d.lengthOfEra = Float.valueOf(String.valueOf(rs.get("length_of_era"))); + d.numPersons = Long.valueOf(String.valueOf(rs.get("num_persons"))); + d.percentPersons = Float.valueOf(String.valueOf(rs.get("percent_persons"))); + listOfResults.add(d); + } + + return listOfResults; + } + + @Path("{conceptId}/drugeraprevalence") + @GET + @Produces(MediaType.APPLICATION_JSON) + public List getDrugEraPrevalenceByGenderAgeYear(@PathParam("sourceKey") String + sourceKey, @PathParam("conceptId") String conceptId) { + Source source = getSourceRepository().findBySourceKey(sourceKey); + String tableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); + String vocabularyTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Vocabulary); + + String sql_statement = ResourceHelper.GetResourceAsString("/resources/cdmresults/sql/getDrugEraPrevalenceByGenderAgeYear.sql"); + sql_statement = SqlRender.renderSql(sql_statement, new String[]{"ohdsi_database_schema", "vocabulary_database_schema", "conceptId"}, new String[]{tableQualifier, vocabularyTableQualifier, conceptId}); + sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect()); + + + List> rows = getSourceJdbcTemplate(source).queryForList(sql_statement); + List listOfResults = new ArrayList(); + for (Map rs : rows) { + DrugEraPrevalence d = new DrugEraPrevalence(); + d.conceptId = Long.valueOf(String.valueOf(rs.get("concept_id"))); + d.trellisName = String.valueOf(rs.get("trellis_name")); + d.seriesName = String.valueOf(rs.get("series_name")); + d.xCalendarYear = Long.valueOf(String.valueOf(rs.get("x_calendar_year"))); + d.yPrevalence1000Pp = Float.valueOf(String.valueOf(rs.get("y_prevalence_1000pp"))); + listOfResults.add(d); + } + + return listOfResults; + } + + @Path("conditionoccurrencetreemap") + @POST + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public List getConditionOccurrenceTreemap(@PathParam("sourceKey") String + sourceKey, String[] identifiers) { + Source source = getSourceRepository().findBySourceKey(sourceKey); + String tableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); + String cdmTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.CDM); + + for (int i = 0; i < identifiers.length; i++) { + identifiers[i] = "'" + identifiers[i] + "'"; + } + + String identifierList = StringUtils.join(identifiers, ","); + String sql_statement = ResourceHelper.GetResourceAsString("/resources/cdmresults/sql/getConditionOccurrenceTreemap.sql"); + sql_statement = SqlRender.renderSql(sql_statement, new String[]{"ohdsi_database_schema", "cdm_database_schema", "conceptIdList"}, new String[]{tableQualifier, cdmTableQualifier, identifierList}); + sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect()); + + + List> rows = getSourceJdbcTemplate(source).queryForList(sql_statement); + List listOfResults = new ArrayList(); + for (Map rs : rows) { + ConditionOccurrenceTreemapNode c = new ConditionOccurrenceTreemapNode(); + c.conceptId = Long.valueOf(String.valueOf(rs.get("concept_id"))); + c.conceptPath = String.valueOf(rs.get("concept_path")); + c.numPersons = Long.valueOf(String.valueOf(rs.get("num_persons"))); + c.percentPersons = Float.valueOf(String.valueOf(rs.get("percent_persons"))); + c.recordsPerPerson = Float.valueOf(String.valueOf(rs.get("records_per_person"))); + listOfResults.add(c); + } + + return listOfResults; + } + + class CDMResultsAnalysisRunner { + + public static final String DASHBOARD = "dashboard"; + public static final String PERSON = "person"; + public static final String BASE_SQL_PATH = "/resources/cdmresults/sql"; + public static final String DRUG = "drug"; + public static final String CONDITION = "condition"; + public static final String CONDITIONERA = "conditionera"; + public static final String OBSERVATIONPERIOD = "observationperiod"; + public static final String HEEL = "heel"; + public static final String PROCEDURE = "procedure"; + public static final String DATADENSITY = "datadensity"; + public static final String OBSERVATION = "observation"; + + public /*static*/ final String[] STANDARD_COLUMNS = new String[]{"cdm_database_schema", + "results_database_schema"/*, "cohortDefinitionId", + "minCovariatePersonCount", "minIntervalPersonCount"*/}; + + public /*static*/ final String[] DRILLDOWN_COLUMNS = new String[]{"cdm_database_schema", + "results_database_schema", /*"cohortDefinitionId", + "minCovariatePersonCount", "minIntervalPersonCount",*/ "conceptId"}; + + private ObjectMapper mapper; + private String sourceDialect; + +// private AchillesVisualizationDataRepository visualizationDataRepository; + + public CDMResultsAnalysisRunner(String sourceDialect) { + + this.sourceDialect = sourceDialect; +// this.visualizationDataRepository = visualizationDataRepository; + mapper = new ObjectMapper(); + } + + public CDMDashboard getDashboard(JdbcTemplate jdbcTemplate, + /*int id,*/ Source source, + /*boolean demographicsOnly,*/ + boolean save) { + + final String key = DASHBOARD; + CDMDashboard dashboard = new CDMDashboard(); + boolean empty = true; + + String ageAtFirstObsSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/observationperiod/ageatfirst.sql", null, source); + if (ageAtFirstObsSql != null) { + dashboard.setAgeAtFirstObservation(jdbcTemplate.query(ageAtFirstObsSql, new ConceptDistributionMapper())); + } + + String genderSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/gender.sql", null, source); + if (genderSql != null) { + dashboard.setGender(jdbcTemplate.query(genderSql, new ConceptCountMapper())); + } + +// if (!demographicsOnly) { + String cumulObsSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/observationperiod/cumulativeduration.sql", null, source); + if (cumulObsSql != null) { + dashboard.setCumulativeObservation(jdbcTemplate.query(cumulObsSql, new CumulativeObservationMapper())); + } + + String obsByMonthSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/observationperiod/observedbymonth.sql", null, source); + if (obsByMonthSql != null) { + dashboard.setObservedByMonth(jdbcTemplate.query(obsByMonthSql, new MonthObservationMapper())); + } +// } + +// if (CollectionUtils.isNotEmpty(dashboard.getAgeAtFirstObservation()) +// || CollectionUtils.isNotEmpty(dashboard.getCumulativeObservation()) +// || CollectionUtils.isNotEmpty(dashboard.getGender()) +// || CollectionUtils.isNotEmpty(dashboard.getObservedByMonth())) { +// empty = false; +// } +// +// if (!empty && save) { +// this.saveEntity(id, source.getSourceId(), key, dashboard); +// } + + return dashboard; + + } + + /** + * Queries for CDM person results for the given source + * + * @param jdbcTemplate JDBCTemplate + * @return CDMPersonSummary + */ + public CDMPersonSummary getPersonResults(JdbcTemplate jdbcTemplate, + final Source source, + boolean save) { + + final String key = PERSON; + CDMPersonSummary person = new CDMPersonSummary(); + boolean empty = true; + Integer id = null; + + String personSummaryData = this.renderTranslateCohortSql(BASE_SQL_PATH + "/report/person/population.sql", null, source); + if (personSummaryData != null) { + person.setYearOfBirth(jdbcTemplate.query(personSummaryData, new ConceptDistributionMapper())); + } + +// String yobStatSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/yearofbirth_stats.sql", id, minCovariatePersonCountParam, minIntervalPersonCountParam, source); +// if (yobStatSql != null) { +// person.setYearOfBirthStats(jdbcTemplate.query(yobStatSql, new CohortStatsMapper())); +// } + + String genderSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/gender.sql", id, /*minCovariatePersonCountParam, minIntervalPersonCountParam,*/ source); + if (genderSql != null) { + person.setGender(jdbcTemplate.query(genderSql, new ConceptCountMapper())); + } + + String raceSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/race.sql", id, /*minCovariatePersonCountParam, minIntervalPersonCountParam,*/ source); + if (raceSql != null) { + person.setRace(jdbcTemplate.query(raceSql, new ConceptCountMapper())); + } + + String ethnicitySql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/ethnicity.sql", id, /*minCovariatePersonCountParam, minIntervalPersonCountParam,*/ source); + if (ethnicitySql != null) { + person.setEthnicity(jdbcTemplate.query(ethnicitySql, new ConceptCountMapper())); + } + +// if (CollectionUtils.isNotEmpty(person.getEthnicity()) +// || CollectionUtils.isNotEmpty(person.getGender()) +// || CollectionUtils.isNotEmpty(person.getRace()) +// || CollectionUtils.isNotEmpty(person.getYearOfBirth()) +// || CollectionUtils.isNotEmpty(person.getYearOfBirthStats())) { +// empty = false; +// } +// +// if (!empty && save) { +// this.saveEntity(id, source.getSourceId(), key, person); +// } + + return person; + } + + /** + * Passes in common params for cdm results, and performs SQL + * translate/render + */ + public String renderTranslateCohortSql(String sqlPath, Integer id, Integer conceptId, + Source source) { + String sql = null; + + String resultsTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); + String vocabularyTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Vocabulary); + + try { + String[] cols; + String[] colValues; + if (conceptId != null) { + cols = DRILLDOWN_COLUMNS; + colValues = new String[]{vocabularyTableQualifier, + resultsTableQualifier, /*String.valueOf(id), + minCovariatePersonCountParam == null ? MIN_COVARIATE_PERSON_COUNT + : minCovariatePersonCountParam, + minIntervalPersonCountParam == null ? MIN_INTERVAL_PERSON_COUNT + : minIntervalPersonCountParam,*/ + String.valueOf(conceptId)}; + } else { + cols = STANDARD_COLUMNS; + colValues = new String[]{vocabularyTableQualifier, + resultsTableQualifier, /*String.valueOf(id), + minCovariatePersonCountParam == null ? MIN_COVARIATE_PERSON_COUNT + : minCovariatePersonCountParam, + minIntervalPersonCountParam == null ? MIN_INTERVAL_PERSON_COUNT + : minIntervalPersonCountParam*/}; + } + + sql = ResourceHelper.GetResourceAsString(sqlPath); + sql = SqlRender.renderSql(sql, cols, colValues); + sql = SqlTranslate.translateSql(sql, sourceDialect, source.getSourceDialect()); + } catch (Exception e) { + log.error(String.format("Unable to translate sql for %s", sql), e); + } + + return sql; + } + + /** + * Passes in common params for cdm results, and performs SQL + * translate/render + */ + public String renderTranslateCohortSql(String sqlPath, Integer id, + Source source) { + return renderTranslateCohortSql(sqlPath, id, null, source); + } + + public CDMDrugSummary getDrugResults(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { + final String key = PERSON; + CDMDrugSummary cdmDrugSummary = new CDMDrugSummary(); + boolean empty = true; + + String personSummaryData = this.renderTranslateCohortSql(BASE_SQL_PATH + "report/person/population.sql", null, source); + + +// if (CollectionUtils.isNotEmpty(person.getEthnicity()) +// || CollectionUtils.isNotEmpty(person.getGender()) +// || CollectionUtils.isNotEmpty(person.getRace()) +// || CollectionUtils.isNotEmpty(person.getYearOfBirth()) +// || CollectionUtils.isNotEmpty(person.getYearOfBirthStats())) { +// empty = false; +// } + +// if (!empty && save) { +// this.saveEntity(id, source.getSourceId(), key, person); +// } + + return cdmDrugSummary; + } + + public CDMProcedureSummary getProcedureResults(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { + final String key = PERSON; + CDMProcedureSummary cdmProcedureSummary = new CDMProcedureSummary(); + boolean empty = true; + + String personSummaryData = this.renderTranslateCohortSql(BASE_SQL_PATH + "report/person/population.sql", null, source); +// if (personSummaryData != null) { +// person.setYearOfBirth(jdbcTemplate.query(yobSql, new ConceptDistributionMapper())); +// } + +// String yobStatSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/yearofbirth_stats.sql", id, minCovariatePersonCountParam, minIntervalPersonCountParam, source); +// if (yobStatSql != null) { +// person.setYearOfBirthStats(jdbcTemplate.query(yobStatSql, new CohortStatsMapper())); +// } +// +// String genderSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/gender.sql", id, minCovariatePersonCountParam, minIntervalPersonCountParam, source); +// if (genderSql != null) { +// person.setGender(jdbcTemplate.query(genderSql, new ConceptCountMapper())); +// } +// +// String raceSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/race.sql", id, minCovariatePersonCountParam, minIntervalPersonCountParam, source); +// if (raceSql != null) { +// person.setRace(jdbcTemplate.query(raceSql, new ConceptCountMapper())); +// } +// +// String ethnicitySql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/ethnicity.sql", id, minCovariatePersonCountParam, minIntervalPersonCountParam, source); +// if (ethnicitySql != null) { +// person.setEthnicity(jdbcTemplate.query(ethnicitySql, new ConceptCountMapper())); +// } +// +// if (CollectionUtils.isNotEmpty(person.getEthnicity()) +// || CollectionUtils.isNotEmpty(person.getGender()) +// || CollectionUtils.isNotEmpty(person.getRace()) +// || CollectionUtils.isNotEmpty(person.getYearOfBirth()) +// || CollectionUtils.isNotEmpty(person.getYearOfBirthStats())) { +// empty = false; +// } +// +// if (!empty && save) { +// this.saveEntity(id, source.getSourceId(), key, person); +// } + + return cdmProcedureSummary; + } + + public CDMAchillesHeel getHeelResults(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { + return new CDMAchillesHeel(); + } + + public CDMObservationPeriod getObservationPeriodResults(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { + return new CDMObservationPeriod(); + } + + public CDMDataDensity getDataDensityResults(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { + return new CDMDataDensity(); + } + + public List getCondition(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { + return new ArrayList(); + } + + public List getConditionEras(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { + return new ArrayList(); + } + + public List getObservationResults(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { + return new ArrayList(); + } + } + } + diff --git a/src/main/resources/resources/cdmresults/sql/report/achillesheel/sqlAchillesHeel.sql b/src/main/resources/resources/cdmresults/sql/report/achillesheel/sqlAchillesHeel.sql new file mode 100644 index 0000000000..5ce0602ea8 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/achillesheel/sqlAchillesHeel.sql @@ -0,0 +1,3 @@ +select analysis_id as AttributeName, ACHILLES_HEEL_warning as AttributeValue +from @results_database_schema.ACHILLES_HEEL_results +order by case when left(ACHILLES_HEEL_warning,5) = 'Error' then 1 else 2 end, analysis_id \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/sqlAgeAtFirstDiagnosis.sql b/src/main/resources/resources/cdmresults/sql/report/condition/sqlAgeAtFirstDiagnosis.sql new file mode 100644 index 0000000000..259d4709aa --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/condition/sqlAgeAtFirstDiagnosis.sql @@ -0,0 +1,17 @@ + select c1.concept_id as concept_id, + c2.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value + from @results_database_schema.ACHILLES_results_dist ard1 + inner join + @vocab_database_schema.concept c1 + on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join + @vocab_database_schema.concept c2 + on ard1.stratum_2 = CAST(c2.concept_id as VARCHAR) + where ard1.analysis_id = 406 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/sqlConditionTreemap.sql b/src/main/resources/resources/cdmresults/sql/report/condition/sqlConditionTreemap.sql new file mode 100644 index 0000000000..841980eb60 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/condition/sqlConditionTreemap.sql @@ -0,0 +1,98 @@ +select concept_hierarchy.concept_id, + isNull(concept_hierarchy.soc_concept_name,'NA') + '||' + isNull(concept_hierarchy.hlgt_concept_name,'NA') + '||' + isNull(concept_hierarchy.hlt_concept_name,'NA') + '||' + isNull(concept_hierarchy.pt_concept_name,'NA') + '||' + isNull(concept_hierarchy.snomed_concept_name,'NA') concept_path, ar1.count_value as num_persons, + round(1.0*ar1.count_value / denom.count_value,5) as percent_persons, + round(1.0*ar2.count_value / ar1.count_value,5) as records_per_person +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 400) ar1 + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 401) ar2 + on ar1.stratum_1 = ar2.stratum_1 + inner join + ( + select snomed.concept_id, + snomed.concept_name as snomed_concept_name, + pt_to_hlt.pt_concept_name, + hlt_to_hlgt.hlt_concept_name, + hlgt_to_soc.hlgt_concept_name, + soc.concept_name as soc_concept_name + from + ( + select concept_id, concept_name + from @vocab_database_schema.concept + where domain_id = 'Condition' + ) snomed + left join + (select c1.concept_id as snomed_concept_id, max(c2.concept_id) as pt_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.domain_id = 'Condition' + and ca1.min_levels_of_separation = 1 + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'MedDRA' + group by c1.concept_id + ) snomed_to_pt + on snomed.concept_id = snomed_to_pt.snomed_concept_id + + left join + (select c1.concept_id as pt_concept_id, c1.concept_name as pt_concept_name, max(c2.concept_id) as hlt_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.vocabulary_id = 'MedDRA' + and ca1.min_levels_of_separation = 1 + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'MedDRA' + group by c1.concept_id, c1.concept_name + ) pt_to_hlt + on snomed_to_pt.pt_concept_id = pt_to_hlt.pt_concept_id + + left join + (select c1.concept_id as hlt_concept_id, c1.concept_name as hlt_concept_name, max(c2.concept_id) as hlgt_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.vocabulary_id = 'MedDRA' + and ca1.min_levels_of_separation = 1 + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'MedDRA' + group by c1.concept_id, c1.concept_name + ) hlt_to_hlgt + on pt_to_hlt.hlt_concept_id = hlt_to_hlgt.hlt_concept_id + + left join + (select c1.concept_id as hlgt_concept_id, c1.concept_name as hlgt_concept_name, max(c2.concept_id) as soc_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.vocabulary_id = 'MedDRA' + and ca1.min_levels_of_separation = 1 + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'MedDRA' + group by c1.concept_id, c1.concept_name + ) hlgt_to_soc + on hlt_to_hlgt.hlgt_concept_id = hlgt_to_soc.hlgt_concept_id + + left join @vocab_database_schema.concept soc + on hlgt_to_soc.soc_concept_id = soc.concept_id + ) concept_hierarchy + on ar1.stratum_1 = CAST(concept_hierarchy.concept_id as VARCHAR) + , + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom + +order by ar1.count_value desc diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/sqlConditionsByType.sql b/src/main/resources/resources/cdmresults/sql/report/condition/sqlConditionsByType.sql new file mode 100644 index 0000000000..c1d54e49f6 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/condition/sqlConditionsByType.sql @@ -0,0 +1,38 @@ +select c1.concept_id as condition_concept_id, + c1.concept_name as condition_concept_name, + c2.concept_group_id as concept_id, + c2.concept_group_name as concept_name, + sum(ar1.count_value) as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join + @vocab_database_schema.concept c1 + on ar1.stratum_1 = cast(c1.concept_id as VARCHAR) + inner join + ( + select concept_id, + case when concept_name like 'Inpatient%' then 10 + when concept_name like 'Outpatient%' then 20 + else concept_id end + + + case when (concept_name like 'Inpatient%' or concept_name like 'Outpatient%' ) and (concept_name like '%primary%' or concept_name like '%1st position%') then 1 + when (concept_name like 'Inpatient%' or concept_name like 'Outpatient%' ) and (concept_name not like '%primary%' and concept_name not like '%1st position%') then 2 + else 0 end as concept_group_id, + case when concept_name like 'Inpatient%' then 'Claim- Inpatient: ' + when concept_name like 'Outpatient%' then 'Claim- Outpatient: ' + else concept_name end + + + '' + + + case when (concept_name like 'Inpatient%' or concept_name like 'Outpatient%' ) and (concept_name like '%primary%' or concept_name like '%1st position%') then 'Primary diagnosis' + when (concept_name like 'Inpatient%' or concept_name like 'Outpatient%' ) and (concept_name not like '%primary%' and concept_name not like '%1st position%') then 'Secondary diagnosis' + else '' end as concept_group_name + from @vocab_database_schema.concept + where lower(domain_id) = 'condition type' + + ) c2 + on ar1.stratum_2 = cast(c2.concept_id as VARCHAR) +where ar1.analysis_id = 405 +group by c1.concept_id, + c1.concept_name, + c2.concept_group_id, + c2.concept_group_name \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/condition/sqlPrevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..87ae401344 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/condition/sqlPrevalenceByGenderAgeYear.sql @@ -0,0 +1,35 @@ +SELECT c1.concept_id AS concept_id, + c1.concept_name as concept_name, + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS VARCHAR) AS trellis_name, --age decile + c2.concept_name AS series_name, --gender + num_stratum_2 AS x_calendar_year, -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), 5) AS y_prevalence_1000pp --prevalence, per 1000 persons +FROM ( + SELECT num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 404 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp +INNER JOIN @vocab_database_schema.concept c1 + ON num_stratum_1 = CAST(c1.concept_id as VARCHAR) +INNER JOIN @vocab_database_schema.concept c2 + ON num_stratum_3 = CAST(c2.concept_id as VARCHAR) +ORDER BY c1.concept_id, + num_stratum_2 diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/condition/sqlPrevalenceByMonth.sql new file mode 100644 index 0000000000..70efc6550f --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/condition/sqlPrevalenceByMonth.sql @@ -0,0 +1,13 @@ + select c1.concept_id as concept_id, + c1.concept_name as concept_name, + num.stratum_2 as x_calendar_month, -- calendar year, note, there could be blanks + round(1000*(1.0*num.count_value/denom.count_value),5) as y_prevalence_1000pp --prevalence, per 1000 persons + from + (select * from @results_database_schema.ACHILLES_results where analysis_id = 402) num + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom + on num.stratum_2 = denom.stratum_1 --calendar year + inner join + @vocab_database_schema.concept c1 + on num.stratum_1 = CAST(c1.concept_id as VARCHAR) +ORDER BY CAST(num.stratum_2 as INT) \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlAgeAtFirstDiagnosis.sql b/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlAgeAtFirstDiagnosis.sql new file mode 100644 index 0000000000..d668b276bb --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlAgeAtFirstDiagnosis.sql @@ -0,0 +1,16 @@ +select c1.concept_id as concept_id, + c2.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join @vocab_database_schema.concept c1 + on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join @vocab_database_schema.concept c2 + on ard1.stratum_2 = CAST(c2.concept_id as VARCHAR) +where ard1.analysis_id = 1006 +and ard1.count_value > 0 diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlConditionEraTreemap.sql b/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlConditionEraTreemap.sql new file mode 100644 index 0000000000..3ef81776b1 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlConditionEraTreemap.sql @@ -0,0 +1,101 @@ +select concept_hierarchy.concept_id, + isNull(concept_hierarchy.soc_concept_name,'NA') + '||' + isNull(concept_hierarchy.hlgt_concept_name,'NA') + '||' + isNull(concept_hierarchy.hlt_concept_name, 'NA') + '||' + isNull(concept_hierarchy.pt_concept_name,'NA') + '||' + isNull(concept_hierarchy.snomed_concept_name,'NA') concept_path, + ar1.count_value as num_persons, + ROUND(1.0*ar1.count_value / denom.count_value,5) as percent_persons, + ROUND(ar2.avg_value,5) as length_of_era +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 1000) ar1 + inner join + (select stratum_1, avg_value from @results_database_schema.ACHILLES_results_dist where analysis_id = 1007) ar2 + on ar1.stratum_1 = ar2.stratum_1 + inner join + ( + select snomed.concept_id, + snomed.concept_name as snomed_concept_name, + pt_to_hlt.pt_concept_name, + hlt_to_hlgt.hlt_concept_name, + hlgt_to_soc.hlgt_concept_name, + soc.concept_name as soc_concept_name + from + ( + select concept_id, concept_name + from @vocab_database_schema.concept + where domain_id = 'Condition' + ) snomed + left join + (select c1.concept_id as snomed_concept_id, max(c2.concept_id) as pt_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.domain_id = 'Condition' + and ca1.min_levels_of_separation = 1 + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'MedDRA' + group by c1.concept_id + ) snomed_to_pt + on snomed.concept_id = snomed_to_pt.snomed_concept_id + + left join + (select c1.concept_id as pt_concept_id, c1.concept_name as pt_concept_name, max(c2.concept_id) as hlt_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.vocabulary_id = 'MedDRA' + and ca1.min_levels_of_separation = 1 + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'MedDRA' + group by c1.concept_id, c1.concept_name + ) pt_to_hlt + on snomed_to_pt.pt_concept_id = pt_to_hlt.pt_concept_id + + left join + (select c1.concept_id as hlt_concept_id, c1.concept_name as hlt_concept_name, max(c2.concept_id) as hlgt_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.vocabulary_id = 'MedDRA' + and ca1.min_levels_of_separation = 1 + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'MedDRA' + group by c1.concept_id, c1.concept_name + ) hlt_to_hlgt + on pt_to_hlt.hlt_concept_id = hlt_to_hlgt.hlt_concept_id + + left join + (select c1.concept_id as hlgt_concept_id, c1.concept_name as hlgt_concept_name, max(c2.concept_id) as soc_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.vocabulary_id = 'MedDRA' + and ca1.min_levels_of_separation = 1 + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'MedDRA' + group by c1.concept_id, c1.concept_name + ) hlgt_to_soc + on hlt_to_hlgt.hlgt_concept_id = hlgt_to_soc.hlgt_concept_id + + left join @vocab_database_schema.concept soc + on hlgt_to_soc.soc_concept_id = soc.concept_id + + + + ) concept_hierarchy + on ar1.stratum_1 = cAST(concept_hierarchy.concept_id as VARCHAR) + , + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom +order by ar1.count_value desc \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlLengthOfEra.sql b/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlLengthOfEra.sql new file mode 100644 index 0000000000..c5603fa3d0 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlLengthOfEra.sql @@ -0,0 +1,14 @@ +select c1.concept_id as concept_id, + 'Length of era' as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) +where ard1.analysis_id = 1007 and ard1.count_value > 0 + + diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlPrevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..ea40d040e3 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlPrevalenceByGenderAgeYear.sql @@ -0,0 +1,34 @@ +SELECT c1.concept_id AS concept_id, + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS VARCHAR) AS trellis_name, --age decile + c2.concept_name AS series_name, --gender + num_stratum_2 AS x_calendar_year, -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), 5) AS y_prevalence_1000pp --prevalence, per 1000 persons +FROM ( + SELECT num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 1004 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp +INNER JOIN @vocab_database_schema.concept c1 + ON num_stratum_1 = CAST(c1.concept_id as VARCHAR) +INNER JOIN @vocab_database_schema.concept c2 + ON num_stratum_3 = CAST(c2.concept_id as VARCHAR) +ORDER BY c1.concept_id, + num_stratum_2 diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlPrevalenceByMonth.sql new file mode 100644 index 0000000000..9c0480a263 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlPrevalenceByMonth.sql @@ -0,0 +1,10 @@ +select c1.concept_id as concept_id, + num.stratum_2 as x_calendar_month, + round(1000*(1.0*num.count_value/denom.count_value),5) as y_prevalence_1000pp +from + (select * from @results_database_schema.ACHILLES_results where analysis_id = 1002) num + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom + on num.stratum_2 = denom.stratum_1 --calendar year + inner join + @vocab_database_schema.concept c1 on num.stratum_1 = CAST(c1.concept_id as VARCHAR) diff --git a/src/main/resources/resources/cdmresults/sql/report/datadensity/conceptsperperson.sql b/src/main/resources/resources/cdmresults/sql/report/datadensity/conceptsperperson.sql new file mode 100644 index 0000000000..b39918d883 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/datadensity/conceptsperperson.sql @@ -0,0 +1,76 @@ +select 'Condition occurrence' as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 403 + +union + +select 'Procedure occurrence' as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 603 + +union + +select 'Drug exposure' as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 703 + +union + +select 'Observation' as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 803 + +union + +select 'Drug era' as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 903 + +union + +select 'Condition era' as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 1003 + diff --git a/src/main/resources/resources/cdmresults/sql/report/datadensity/recordsperperson.sql b/src/main/resources/resources/cdmresults/sql/report/datadensity/recordsperperson.sql new file mode 100644 index 0000000000..7e6a1787de --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/datadensity/recordsperperson.sql @@ -0,0 +1,27 @@ +select t1.table_name as SERIES_NAME, + t1.stratum_1 as X_CALENDAR_MONTH, + round(1.0*t1.count_value/denom.count_value,5) as Y_RECORD_COUNT +from +( + select 'Visit occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 220 + union all + select 'Condition occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 420 + union all + select 'Death' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 502 + union all + select 'Procedure occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 620 + union all + select 'Drug exposure' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 720 + union all + select 'Observation' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 820 + union all + select 'Drug era' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 920 + union all + select 'Condition era' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 1020 + union all + select 'Observation period' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 111 +) t1 +inner join +(select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom +on t1.stratum_1 = denom.stratum_1 +ORDER BY SERIES_NAME, CAST(t1.stratum_1 as INT) diff --git a/src/main/resources/resources/cdmresults/sql/report/datadensity/totalrecords.sql b/src/main/resources/resources/cdmresults/sql/report/datadensity/totalrecords.sql new file mode 100644 index 0000000000..78d7508f17 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/datadensity/totalrecords.sql @@ -0,0 +1,24 @@ +select table_name as SERIES_NAME, + stratum_1 as X_CALENDAR_MONTH, + count_value as Y_RECORD_COUNT +from +( + select 'Visit occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 220 + union all + select 'Condition occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 420 + union all + select 'Death' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 502 + union all + select 'Procedure occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 620 + union all + select 'Drug exposure' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 720 + union all + select 'Observation' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 820 + union all + select 'Drug era' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 920 + union all + select 'Condition era' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 1020 + union all + select 'Observation period' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 111 +) t1 +ORDER BY SERIES_NAME, CAST(stratum_1 as INT) \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/death/sqlAgeAtDeath.sql b/src/main/resources/resources/cdmresults/sql/report/death/sqlAgeAtDeath.sql new file mode 100644 index 0000000000..9c61cbf843 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/death/sqlAgeAtDeath.sql @@ -0,0 +1,12 @@ +select c2.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as P10_value, + ard1.p25_value as P25_value, + ard1.median_value as median_value, + ard1.p75_value as P75_value, + ard1.p90_value as P90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join + @vocab_database_schema.concept c2 on ard1.stratum_1 = CAST(c2.concept_id as VARCHAR) +where ard1.analysis_id = 506 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/death/sqlDeathByType.sql b/src/main/resources/resources/cdmresults/sql/report/death/sqlDeathByType.sql new file mode 100644 index 0000000000..570560aaa3 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/death/sqlDeathByType.sql @@ -0,0 +1,6 @@ +select c2.concept_id as concept_id, + c2.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join @vocab_database_schema.concept c2 on ar1.stratum_1 = CAST(c2.concept_id as VARCHAR) +where ar1.analysis_id = 505 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..7127c7937f --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByGenderAgeYear.sql @@ -0,0 +1,13 @@ +select cast(cast(num.stratum_3 as int)*10 as varchar) + '-' + cast((cast(num.stratum_3 as int)+1)*10-1 as varchar) as trellis_name, --age decile + c2.concept_name as series_name, --gender + num.stratum_1 as x_calendar_year, -- calendar year, note, there could be blanks + ROUND(1000*(1.0*num.count_value/denom.count_value),5) as y_prevalence_1000pp --prevalence, per 1000 persons +from + (select * from @results_database_schema.ACHILLES_results where analysis_id = 504) num + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 116) denom on num.stratum_1 = denom.stratum_1 --calendar year + and num.stratum_2 = denom.stratum_2 --gender + and num.stratum_3 = denom.stratum_3 --age decile + inner join @vocab_database_schema.concept c2 on num.stratum_2 = CAST(c2.concept_id as VARCHAR) +where c2.concept_id in (8507, 8532) + diff --git a/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByMonth.sql new file mode 100644 index 0000000000..39235d7ab1 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByMonth.sql @@ -0,0 +1,7 @@ +select num.stratum_1 as x_calendar_month, -- calendar year, note, there could be blanks + 1000*(1.0*num.count_value/denom.count_value) as y_prevalence_1000pp --prevalence, per 1000 persons +from + (select * from @results_database_schema.ACHILLES_results where analysis_id = 502) num + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom on num.stratum_1 = denom.stratum_1 --calendar year + diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlAgeAtFirstExposure.sql b/src/main/resources/resources/cdmresults/sql/report/drug/sqlAgeAtFirstExposure.sql new file mode 100644 index 0000000000..94964450df --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/sqlAgeAtFirstExposure.sql @@ -0,0 +1,18 @@ +select c1.concept_id as drug_concept_id, + c2.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join + @vocab_database_schema.concept c1 + on ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR) + inner join + @vocab_database_schema.concept c2 + on ard1.stratum_2 = CAST(c2.concept_id AS VARCHAR) +where ard1.analysis_id = 706 +and ard1.count_value > 0 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlDaysSupplyDistribution.sql b/src/main/resources/resources/cdmresults/sql/report/drug/sqlDaysSupplyDistribution.sql new file mode 100644 index 0000000000..69d161a4b4 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/sqlDaysSupplyDistribution.sql @@ -0,0 +1,15 @@ +select c1.concept_id as drug_concept_id, + 'Days supply' as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join + @vocab_database_schema.concept c1 + on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) +where ard1.analysis_id = 715 +and ard1.count_value > 0 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlDrugTreemap.sql b/src/main/resources/resources/cdmresults/sql/report/drug/sqlDrugTreemap.sql new file mode 100644 index 0000000000..953abe82af --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/sqlDrugTreemap.sql @@ -0,0 +1,98 @@ +select concept_hierarchy.concept_id, + isnull(concept_hierarchy.atc1_concept_name,'NA') + '||' + + isnull(concept_hierarchy.atc3_concept_name,'NA') + '||' + + isnull(concept_hierarchy.atc5_concept_name,'NA') + '||' + + isnull(concept_hierarchy.rxnorm_ingredient_concept_name,'NA') + '||' + + concept_hierarchy.rxnorm_concept_name concept_path, + ar1.count_value as num_persons, + round(1.0*ar1.count_value / denom.count_value,5) as percent_persons, + round(1.0*ar2.count_value / ar1.count_value,5) as records_per_person +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 700) ar1 + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 701) ar2 + on ar1.stratum_1 = ar2.stratum_1 + inner join + ( + select rxnorm.concept_id, + rxnorm.concept_name as rxnorm_concept_name, + rxnorm.rxnorm_ingredient_concept_name, + atc5_to_atc3.atc5_concept_name, + atc3_to_atc1.atc3_concept_name, + atc1.concept_name as atc1_concept_name + from + ( + select c1.concept_id, + c1.concept_name, + c2.concept_id as rxnorm_ingredient_concept_id, + c2.concept_name as RxNorm_ingredient_concept_name + from @vocab_database_schema.concept c1 + inner join @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.domain_id = 'Drug' + inner join @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.domain_id = 'Drug' + and c2.concept_class_id = 'Ingredient' + ) rxnorm + left join + (select c1.concept_id as rxnorm_ingredient_concept_id, max(c2.concept_id) as atc5_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.domain_id = 'Drug' + and c1.concept_class_id = 'Ingredient' + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'ATC' + and c2.concept_class_id = 'ATC 4th' + group by c1.concept_id + ) rxnorm_to_atc5 + on rxnorm.rxnorm_ingredient_concept_id = rxnorm_to_atc5.rxnorm_ingredient_concept_id + + left join + (select c1.concept_id as atc5_concept_id, c1.concept_name as atc5_concept_name, max(c2.concept_id) as atc3_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.vocabulary_id = 'ATC' + and c1.concept_class_id = 'ATC 4th' + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'ATC' + and c2.concept_class_id = 'ATC 2nd' + group by c1.concept_id, c1.concept_name + ) atc5_to_atc3 + on rxnorm_to_atc5.atc5_concept_id = atc5_to_atc3.atc5_concept_id + + left join + (select c1.concept_id as atc3_concept_id, c1.concept_name as atc3_concept_name, max(c2.concept_id) as atc1_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.vocabulary_id = 'ATC' + and c1.concept_class_id = 'ATC 2nd' + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'ATC' + and c2.concept_class_id = 'ATC 1st' + group by c1.concept_id, c1.concept_name + ) atc3_to_atc1 + on atc5_to_atc3.atc3_concept_id = atc3_to_atc1.atc3_concept_id + + left join @vocab_database_schema.concept atc1 + on atc3_to_atc1.atc1_concept_id = atc1.concept_id + ) concept_hierarchy + on ar1.stratum_1 = CAST(concept_hierarchy.concept_id AS VARCHAR) + , + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom + +order by ar1.count_value desc \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlDrugsByType.sql b/src/main/resources/resources/cdmresults/sql/report/drug/sqlDrugsByType.sql new file mode 100644 index 0000000000..09cadcdfbf --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/sqlDrugsByType.sql @@ -0,0 +1,12 @@ +select c1.concept_id as drug_concept_id, + c2.concept_id as concept_id, + c2.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join + @vocab_database_schema.concept c1 + on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) + inner join + @vocab_database_schema.concept c2 + on ar1.stratum_2 = CAST(c2.concept_id AS VARCHAR) +where ar1.analysis_id = 705 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/drug/sqlPrevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..f47fc292fb --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/sqlPrevalenceByGenderAgeYear.sql @@ -0,0 +1,33 @@ +SELECT c1.concept_id AS concept_id, + c1.concept_name as concept_name, + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS VARCHAR) AS trellis_name, --age decile + c2.concept_name AS series_name, --gender + num_stratum_2 AS x_calendar_year, -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), 5) AS y_prevalence_1000pp --prevalence, per 1000 persons +FROM ( + SELECT num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 704 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp +INNER JOIN @vocab_database_schema.concept c1 + ON num_stratum_1 = CAST(c1.concept_id as VARCHAR) +INNER JOIN @vocab_database_schema.concept c2 + ON num_stratum_3 = CAST(c2.concept_id as VARCHAR) diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/drug/sqlPrevalenceByMonth.sql new file mode 100644 index 0000000000..7392df45ee --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/sqlPrevalenceByMonth.sql @@ -0,0 +1,12 @@ +select c1.concept_id as concept_id, + c1.concept_name as concept_name, + num.stratum_2 as x_calendar_month, + round(1000*(1.0*num.count_value/denom.count_value),5) as y_prevalence_1000pp +from + (select * from @results_database_schema.ACHILLES_results where analysis_id = 702) num + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom + on num.stratum_2 = denom.stratum_1 --calendar year + inner join + @vocab_database_schema.concept c1 + on num.stratum_1 = CAST(c1.concept_id as VARCHAR) diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlQuantityDistribution.sql b/src/main/resources/resources/cdmresults/sql/report/drug/sqlQuantityDistribution.sql new file mode 100644 index 0000000000..388a34eaac --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/sqlQuantityDistribution.sql @@ -0,0 +1,15 @@ +select c1.concept_id as drug_concept_id, + 'Quantity' as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join + @vocab_database_schema.concept c1 + on ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR) +where ard1.analysis_id = 717 +and ard1.count_value > 0 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlRefillsDistribution.sql b/src/main/resources/resources/cdmresults/sql/report/drug/sqlRefillsDistribution.sql new file mode 100644 index 0000000000..fc2e82fd75 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/sqlRefillsDistribution.sql @@ -0,0 +1,15 @@ +select c1.concept_id as drug_concept_id, + 'Refills' as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join + @vocab_database_schema.concept c1 + on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) +where ard1.analysis_id = 716 +and ard1.count_value > 0 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/sqlAgeAtFirstExposure.sql b/src/main/resources/resources/cdmresults/sql/report/drugera/sqlAgeAtFirstExposure.sql new file mode 100644 index 0000000000..d1a6822bfa --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drugera/sqlAgeAtFirstExposure.sql @@ -0,0 +1,18 @@ +select c1.concept_id as concept_id, + c2.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join + @vocab_database_schema.concept c1 + on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join + @vocab_database_schema.concept c2 + on ard1.stratum_2 = cast(c2.concept_id as VARCHAR) +where ard1.analysis_id = 906 +and ard1.count_value > 0 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/sqlDrugEraTreemap.sql b/src/main/resources/resources/cdmresults/sql/report/drugera/sqlDrugEraTreemap.sql new file mode 100644 index 0000000000..4c005d7891 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drugera/sqlDrugEraTreemap.sql @@ -0,0 +1,89 @@ +select concept_hierarchy.rxnorm_ingredient_concept_id concept_id, + isnull(concept_hierarchy.atc1_concept_name,'NA') + '||' + + isnull(concept_hierarchy.atc3_concept_name,'NA') + '||' + + isnull(concept_hierarchy.atc5_concept_name,'NA') + '||' + + isnull(concept_hierarchy.rxnorm_ingredient_concept_name,'||') concept_path, + ar1.count_value as num_persons, + 1.0*ar1.count_value / denom.count_value as percent_persons, + ar2.avg_value as length_of_era +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 900) ar1 + inner join + (select stratum_1, avg_value from @results_database_schema.ACHILLES_results_dist where analysis_id = 907) ar2 + on ar1.stratum_1 = ar2.stratum_1 + inner join + ( + select rxnorm.rxnorm_ingredient_concept_id, + rxnorm.rxnorm_ingredient_concept_name, + atc5_to_atc3.atc5_concept_name, + atc3_to_atc1.atc3_concept_name, + atc1.concept_name as atc1_concept_name + from + ( + select c2.concept_id as rxnorm_ingredient_concept_id, + c2.concept_name as RxNorm_ingredient_concept_name + from + @vocab_database_schema.concept c2 + where + c2.domain_id = 'Drug' + and c2.concept_class_id = 'Ingredient' + ) rxnorm + left join + (select c1.concept_id as rxnorm_ingredient_concept_id, max(c2.concept_id) as atc5_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.domain_id = 'Drug' + and c1.concept_class_id = 'Ingredient' + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'ATC' + and c2.concept_class_id = 'ATC 4th' + group by c1.concept_id + ) rxnorm_to_atc5 + on rxnorm.rxnorm_ingredient_concept_id = rxnorm_to_atc5.rxnorm_ingredient_concept_id + + left join + (select c1.concept_id as atc5_concept_id, c1.concept_name as atc5_concept_name, max(c2.concept_id) as atc3_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.vocabulary_id = 'ATC' + and c1.concept_class_id = 'ATC 4th' + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'ATC' + and c2.concept_class_id = 'ATC 2nd' + group by c1.concept_id, c1.concept_name + ) atc5_to_atc3 + on rxnorm_to_atc5.atc5_concept_id = atc5_to_atc3.atc5_concept_id + + left join + (select c1.concept_id as atc3_concept_id, c1.concept_name as atc3_concept_name, max(c2.concept_id) as atc1_concept_id + from + @vocab_database_schema.concept c1 + inner join + @vocab_database_schema.concept_ancestor ca1 + on c1.concept_id = ca1.descendant_concept_id + and c1.vocabulary_id = 'ATC' + and c1.concept_class_id = 'ATC 2nd' + inner join + @vocab_database_schema.concept c2 + on ca1.ancestor_concept_id = c2.concept_id + and c2.vocabulary_id = 'ATC' + and c2.concept_class_id = 'ATC 1st' + group by c1.concept_id, c1.concept_name + ) atc3_to_atc1 + on atc5_to_atc3.atc3_concept_id = atc3_to_atc1.atc3_concept_id + + left join @vocab_database_schema.concept atc1 + on atc3_to_atc1.atc1_concept_id = atc1.concept_id + ) concept_hierarchy + on ar1.stratum_1 = CAST(concept_hierarchy.rxnorm_ingredient_concept_id AS VARCHAR) + , + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/sqlLengthOfEra.sql b/src/main/resources/resources/cdmresults/sql/report/drugera/sqlLengthOfEra.sql new file mode 100644 index 0000000000..9916915b6c --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drugera/sqlLengthOfEra.sql @@ -0,0 +1,15 @@ +select c1.concept_id as concept_id, + 'Length of Era' as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join + @vocab_database_schema.concept c1 + on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) +where ard1.analysis_id = 907 +and ard1.count_value > 0 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/drugera/sqlPrevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..6e0d31b482 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drugera/sqlPrevalenceByGenderAgeYear.sql @@ -0,0 +1,33 @@ +SELECT c1.concept_id AS concept_id, + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS VARCHAR) AS trellis_name, --age decile + c2.concept_name AS series_name, --gender + num_stratum_2 AS x_calendar_year, -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), 5) AS y_prevalence_1000pp --prevalence, per 1000 persons +FROM ( + SELECT num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 904 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp +INNER JOIN @vocab_database_schema.concept c1 + ON num_stratum_1 = CAST(c1.concept_id as VARCHAR) +INNER JOIN @vocab_database_schema.concept c2 + ON num_stratum_3 = CAST(c2.concept_id as VARCHAR) + diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/drugera/sqlPrevalenceByMonth.sql new file mode 100644 index 0000000000..e991f79851 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drugera/sqlPrevalenceByMonth.sql @@ -0,0 +1,11 @@ +select c1.concept_id as concept_id, + num.stratum_2 as x_calendar_month, + round(1000*(1.0*num.count_value/denom.count_value),5) as y_prevalence_1000pp +from + (select * from @results_database_schema.ACHILLES_results where analysis_id = 902) num + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom + on num.stratum_2 = denom.stratum_1 + inner join + @vocab_database_schema.concept c1 + on num.stratum_1 = CAST(c1.concept_id as VARCHAR) diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlAgeAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlAgeAtFirstOccurrence.sql new file mode 100644 index 0000000000..a7c7e7f1f2 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlAgeAtFirstOccurrence.sql @@ -0,0 +1,13 @@ +select c1.concept_id as CONCEPT_ID, + c2.concept_name as CATEGORY, + ard1.min_value as MIN_VALUE, + ard1.p10_value as P10_VALUE, + ard1.p25_value as P25_VALUE, + ard1.median_value as MEDIAN_VALUE, + ard1.p75_value as P75_VALUE, + ard1.p90_value as P90_VALUE, + ard1.max_value as MAX_VALUE +from @results_database_schema.ACHILLES_results_dist ard1 + inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join @vocab_database_schema.concept c2 on ard1.stratum_2 = CAST(c2.concept_id as VARCHAR) +where ard1.analysis_id = 1806 diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlLowerLimitDistribution.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlLowerLimitDistribution.sql new file mode 100644 index 0000000000..e69a9df92a --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlLowerLimitDistribution.sql @@ -0,0 +1,14 @@ +select c1.concept_id as concept_id, + c2.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as P10_value, + ard1.p25_value as P25_value, + ard1.median_value as median_value, + ard1.p75_value as P75_value, + ard1.p90_value as P90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR) + inner join @vocab_database_schema.concept c2 on ard1.stratum_2 = cast(c2.concept_id AS VARCHAR) +where ard1.analysis_id = 1816 +and ard1.count_value > 0 diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementTreemap.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementTreemap.sql new file mode 100644 index 0000000000..8e661d9558 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementTreemap.sql @@ -0,0 +1,30 @@ +select concept_hierarchy.concept_id, + isNull(concept_hierarchy.level3_concept_name,'NA') + + '||' + isNull(concept_hierarchy.level2_concept_name,'NA') + + '||' + isNull(concept_hierarchy.level1_concept_name,'NA') + + '||' + isNull(concept_hierarchy.concept_name, 'NA') as concept_path, + ar1.count_value as num_persons, + 1.0*ar1.count_value / denom.count_value as percent_persons, + 1.0*ar2.count_value / ar1.count_value as records_per_person +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 1800) ar1 + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 1801) ar2 + on ar1.stratum_1 = ar2.stratum_1 + inner join + ( + select m.concept_id, m.concept_name, max(c1.concept_name) as level1_concept_name, max(c2.concept_name) as level2_concept_name, max(c3.concept_name) as level3_concept_name + from + ( + select distinct concept_id, concept_name + from @vocab_database_schema.concept c + join @cdm_database_schema.measurement m on c.concept_id = m.measurement_concept_id + ) m left join @vocab_database_schema.concept_ancestor ca1 on m.concept_id = ca1.DESCENDANT_CONCEPT_ID and ca1.min_levels_of_separation = 1 + left join @vocab_database_schema.concept c1 on ca1.ANCESTOR_CONCEPT_ID = c1.concept_id + left join @vocab_database_schema.concept_ancestor ca2 on c1.concept_id = ca2.DESCENDANT_CONCEPT_ID and ca2.min_levels_of_separation = 1 + left join @vocab_database_schema.concept c2 on ca2.ANCESTOR_CONCEPT_ID = c2.concept_id + left join @vocab_database_schema.concept_ancestor ca3 on c2.concept_id = ca3.DESCENDANT_CONCEPT_ID and ca3.min_levels_of_separation = 1 + left join @vocab_database_schema.concept c3 on ca3.ANCESTOR_CONCEPT_ID = c3.concept_id + group by m.concept_id, m.concept_name + ) concept_hierarchy on ar1.stratum_1 = CAST(concept_hierarchy.concept_id as VARCHAR), + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom +order by ar1.count_value desc diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementValueDistribution.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementValueDistribution.sql new file mode 100644 index 0000000000..7930e747df --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementValueDistribution.sql @@ -0,0 +1,15 @@ +select c1.concept_id as concept_id, + c2.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as P10_value, + ard1.p25_value as P25_value, + ard1.median_value as median_value, + ard1.p75_value as P75_value, + ard1.p90_value as P90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join @vocab_database_schema.concept c2 on ard1.stratum_2 = CAST(c2.concept_id as VARCHAR) +where ard1.analysis_id = 1815 +and ard1.count_value > 0 + diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementsByType.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementsByType.sql new file mode 100644 index 0000000000..864af4f022 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementsByType.sql @@ -0,0 +1,9 @@ +select c1.concept_id as MEASUREMENT_CONCEPT_ID, + c1.concept_name as MEASUREMENT_CONCEPT_NAME, + c2.concept_id as CONCEPT_ID, + c2.concept_name as CONCEPT_NAME, + ar1.count_value as COUNT_VALUE +from @results_database_schema.ACHILLES_results ar1 + inner join @vocab_database_schema.concept c1 on ar1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join @vocab_database_schema.concept c2 on ar1.stratum_2 = CAST(c2.concept_id as VARCHAR) +where ar1.analysis_id = 1805 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlPrevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..4b930bdef1 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlPrevalenceByGenderAgeYear.sql @@ -0,0 +1,34 @@ +SELECT c1.concept_id AS concept_id, + c1.concept_name as concept_name, + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS VARCHAR) AS trellis_name, --age decile + c2.concept_name AS series_name, --gender + num_stratum_2 AS x_calendar_year, -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), 5) AS y_prevalence_1000pp --prevalence, per 1000 persons +FROM ( + SELECT num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 1804 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp +INNER JOIN @vocab_database_schema.concept c1 + ON num_stratum_1 = CAST(c1.concept_id as VARCHAR) +INNER JOIN @vocab_database_schema.concept c2 + ON num_stratum_3 = CAST(c2.concept_id as VARCHAR) + diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlPrevalenceByMonth.sql new file mode 100644 index 0000000000..bac07e3268 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlPrevalenceByMonth.sql @@ -0,0 +1,10 @@ +select c1.concept_id as CONCEPT_ID, --all rows for all concepts, but you may split by conceptid + c1.concept_name as CONCEPT_NAME, + num.stratum_2 as X_CALENDAR_MONTH, -- calendar year, note, there could be blanks + round(1000*(1.0*num.count_value/denom.count_value),5) as Y_PREVALENCE_1000PP --prevalence, per 1000 persons +from + (select * from @results_database_schema.ACHILLES_results where analysis_id = 1802) num + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom on num.stratum_2 = denom.stratum_1 --calendar year + inner join @vocab_database_schema.concept c1 on num.stratum_1 = CAST(c1.concept_id as VARCHAR) + diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlRecordsByUnit.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlRecordsByUnit.sql new file mode 100644 index 0000000000..5308949635 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlRecordsByUnit.sql @@ -0,0 +1,9 @@ +select c1.concept_id as MEASUREMENT_CONCEPT_ID, + c1.concept_name as MEASUREMENT_CONCEPT_NAME, + c2.concept_id as concept_id, + c2.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join @vocab_database_schema.concept c1 on ar1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join @vocab_database_schema.concept c2 on ar1.stratum_2 = CAST(c2.concept_id as VARCHAR) +where ar1.analysis_id = 1807 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlUpperLimitDistribution.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlUpperLimitDistribution.sql new file mode 100644 index 0000000000..6fe13d8c74 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlUpperLimitDistribution.sql @@ -0,0 +1,14 @@ +select c1.concept_id as concept_id, + c2.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as P10_value, + ard1.p25_value as P25_value, + ard1.median_value as median_value, + ard1.p75_value as P75_value, + ard1.p90_value as P90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join @vocab_database_schema.concept c2 on ard1.stratum_2 = CAST(c2.concept_id as VARCHAR) +where ard1.analysis_id = 1817 +and ard1.count_value > 0 diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlValuesRelativeToNorm.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlValuesRelativeToNorm.sql new file mode 100644 index 0000000000..f6114e1318 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/sqlValuesRelativeToNorm.sql @@ -0,0 +1,9 @@ +select c1.concept_id as MEASUREMENT_CONCEPT_ID, + c1.concept_name as MEASUREMENT_CONCEPT_NAME, + c2.concept_id as concept_id, + c2.concept_name + ': ' + ar1.stratum_3 as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join @vocab_database_schema.concept c1 on ar1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join @vocab_database_schema.concept c2 on ar1.stratum_2 = CAST(c2.concept_id as VARCHAR) +where ar1.analysis_id = 1818 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/sqlAgeAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/report/observation/sqlAgeAtFirstOccurrence.sql new file mode 100644 index 0000000000..6fe9120c27 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observation/sqlAgeAtFirstOccurrence.sql @@ -0,0 +1,13 @@ +select c1.concept_id as CONCEPT_ID, + c2.concept_name as CATEGORY, + ard1.min_value as MIN_VALUE, + ard1.p10_value as P10_VALUE, + ard1.p25_value as P25_VALUE, + ard1.median_value as MEDIAN_VALUE, + ard1.p75_value as P75_VALUE, + ard1.p90_value as P90_VALUE, + ard1.max_value as MAX_VALUE +from @results_database_schema.ACHILLES_results_dist ard1 + inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join @vocab_database_schema.concept c2 on ard1.stratum_2 = CAST(c2.concept_id as VARCHAR) +where ard1.analysis_id = 806 diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/sqlObservationTreemap.sql b/src/main/resources/resources/cdmresults/sql/report/observation/sqlObservationTreemap.sql new file mode 100644 index 0000000000..6ad78fe4c0 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observation/sqlObservationTreemap.sql @@ -0,0 +1,30 @@ +select concept_hierarchy.concept_id, + isNull(concept_hierarchy.level3_concept_name,'NA') + + '||' + isNull(concept_hierarchy.level2_concept_name,'NA') + + '||' + isNull(concept_hierarchy.level1_concept_name,'NA') + + '||' + isNull(concept_hierarchy.concept_name, 'NA') as concept_path, + ar1.count_value as num_persons, + 1.0*ar1.count_value / denom.count_value as percent_persons, + 1.0*ar2.count_value / ar1.count_value as records_per_person +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 800) ar1 + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 801) ar2 + on ar1.stratum_1 = ar2.stratum_1 + inner join + ( + select obs.concept_id, obs.concept_name, max(c1.concept_name) as level1_concept_name, max(c2.concept_name) as level2_concept_name, max(c3.concept_name) as level3_concept_name + from + ( + select concept_id, concept_name + from @vocab_database_schema.concept + where domain_id = 'Observation' + ) obs left join @vocab_database_schema.concept_ancestor ca1 on obs.concept_id = ca1.DESCENDANT_CONCEPT_ID and ca1.min_levels_of_separation = 1 + left join @vocab_database_schema.concept c1 on ca1.ANCESTOR_CONCEPT_ID = c1.concept_id + left join @vocab_database_schema.concept_ancestor ca2 on c1.concept_id = ca2.DESCENDANT_CONCEPT_ID and ca2.min_levels_of_separation = 1 + left join @vocab_database_schema.concept c2 on ca2.ANCESTOR_CONCEPT_ID = c2.concept_id + left join @vocab_database_schema.concept_ancestor ca3 on c2.concept_id = ca3.DESCENDANT_CONCEPT_ID and ca3.min_levels_of_separation = 1 + left join @vocab_database_schema.concept c3 on ca3.ANCESTOR_CONCEPT_ID = c3.concept_id + group by obs.concept_id, obs.concept_name + ) concept_hierarchy on ar1.stratum_1 = CAST(concept_hierarchy.concept_id as VARCHAR), + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom +order by ar1.count_value desc diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/sqlObservationsByType.sql b/src/main/resources/resources/cdmresults/sql/report/observation/sqlObservationsByType.sql new file mode 100644 index 0000000000..7099d0fcbd --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observation/sqlObservationsByType.sql @@ -0,0 +1,9 @@ +select c1.concept_id as OBSERVATION_CONCEPT_ID, + c1.concept_name as OBSERVATION_CONCEPT_NAME, + c2.concept_id as CONCEPT_ID, + c2.concept_name as CONCEPT_NAME, + ar1.count_value as COUNT_VALUE +from @results_database_schema.ACHILLES_results ar1 + inner join @vocab_database_schema.concept c1 on ar1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join @vocab_database_schema.concept c2 on ar1.stratum_2 = CAST(c2.concept_id as VARCHAR) +where ar1.analysis_id = 805 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/observation/sqlPrevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..1db95c2e07 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observation/sqlPrevalenceByGenderAgeYear.sql @@ -0,0 +1,34 @@ +SELECT c1.concept_id AS concept_id, + c1.concept_name as concept_name, + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS VARCHAR) AS trellis_name, --age decile + c2.concept_name AS series_name, --gender + num_stratum_2 AS x_calendar_year, -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), 5) AS y_prevalence_1000pp --prevalence, per 1000 persons +FROM ( + SELECT num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 804 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp +INNER JOIN @vocab_database_schema.concept c1 + ON num_stratum_1 = CAST(c1.concept_id as VARCHAR) +INNER JOIN @vocab_database_schema.concept c2 + ON num_stratum_3 = CAST(c2.concept_id as VARCHAR) + diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/observation/sqlPrevalenceByMonth.sql new file mode 100644 index 0000000000..c81776b9bc --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observation/sqlPrevalenceByMonth.sql @@ -0,0 +1,10 @@ +select c1.concept_id as CONCEPT_ID, --all rows for all concepts, but you may split by conceptid + c1.concept_name as CONCEPT_NAME, + num.stratum_2 as X_CALENDAR_MONTH, -- calendar year, note, there could be blanks + round(1000*(1.0*num.count_value/denom.count_value),5) as Y_PREVALENCE_1000PP --prevalence, per 1000 persons +from + (select * from @results_database_schema.ACHILLES_results where analysis_id = 802) num + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom on num.stratum_2 = denom.stratum_1 --calendar year + inner join @vocab_database_schema.concept c1 on num.stratum_1 = CAST(c1.concept_id as VARCHAR) + diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/ageatfirst.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/ageatfirst.sql new file mode 100644 index 0000000000..00956a3c6e --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/ageatfirst.sql @@ -0,0 +1,10 @@ +select cast(ar1.stratum_1 as int) as interval_index, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from +( + select * from @results_database_schema.ACHILLES_results where analysis_id = 101 +) ar1, +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/agebygender.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/agebygender.sql new file mode 100644 index 0000000000..66992b463d --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/agebygender.sql @@ -0,0 +1,11 @@ +select c1.concept_name as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) +where ard1.analysis_id = 104 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/cumulativeduration.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/cumulativeduration.sql new file mode 100644 index 0000000000..7542e49c47 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/cumulativeduration.sql @@ -0,0 +1,13 @@ +select 'Length of observation' as series_name, + cast(ar1.stratum_1 as int)*30 as x_length_of_observation, + round(1.0*sum(ar2.count_value) / denom.count_value,5) as y_percent_persons +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 108) ar1 +inner join +( + select * from @results_database_schema.ACHILLES_results where analysis_id = 108 +) ar2 on ar1.analysis_id = ar2.analysis_id and cast(ar1.stratum_1 as int) <= cast(ar2.stratum_1 as int), +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom +group by cast(ar1.stratum_1 as int)*30, denom.count_value +order by cast(ar1.stratum_1 as int)*30 asc diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_data.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_data.sql new file mode 100644 index 0000000000..ca38aba3a3 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_data.sql @@ -0,0 +1,9 @@ +select cast(ar1.stratum_1 as int) as interval_index, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from @results_database_schema.ACHILLES_analysis aa1 +inner join @results_database_schema.ACHILLES_results ar1 on aa1.analysis_id = ar1.analysis_id, +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom +where aa1.analysis_id = 108 diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_stats.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_stats.sql new file mode 100644 index 0000000000..52f311c927 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_stats.sql @@ -0,0 +1,9 @@ +select min(cast(ar1.stratum_1 as int)) * 30 as min_value, + max(cast(ar1.stratum_1 as int)) * 30 as max_value, + 30 as interval_size +from @results_database_schema.ACHILLES_analysis aa1 +inner join @results_database_schema.ACHILLES_results ar1 on aa1.analysis_id = ar1.analysis_id, +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom +where aa1.analysis_id = 108 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbyage.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbyage.sql new file mode 100644 index 0000000000..f69160bcae --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbyage.sql @@ -0,0 +1,10 @@ + select cast(cast(ard1.stratum_1 as int)*10 as varchar) + '-' + cast((cast(ard1.stratum_1 as int)+1)*10-1 as varchar) as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 107 diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbygender.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbygender.sql new file mode 100644 index 0000000000..1383c2bb88 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbygender.sql @@ -0,0 +1,11 @@ +select c1.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) +where ard1.analysis_id = 106 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbymonth.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbymonth.sql new file mode 100644 index 0000000000..f4143f1c7f --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbymonth.sql @@ -0,0 +1,7 @@ +select cast(ar1.stratum_1 as int) as month_year, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 110) ar1, + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom + + \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_data.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_data.sql new file mode 100644 index 0000000000..084ac45880 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_data.sql @@ -0,0 +1,14 @@ +select cast(ar1.stratum_1 as int) - MinValue.MinValue as interval_index, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from +( + select * from @results_database_schema.ACHILLES_results where analysis_id = 109 +) ar1, +( + select min(cast(stratum_1 as int)) as MinValue + from @results_database_schema.ACHILLES_results where analysis_id = 109 +) MinValue, +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_stats.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_stats.sql new file mode 100644 index 0000000000..048971af81 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_stats.sql @@ -0,0 +1,5 @@ +select min(cast(ar1.stratum_1 as int)) as min_value, + max(cast(ar1.stratum_1 as int)) as max_value, + 1 as interval_size +from @results_database_schema.ACHILLES_results ar1 +where ar1.analysis_id = 109 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/periodsperperson.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/periodsperperson.sql new file mode 100644 index 0000000000..67d048940d --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/periodsperperson.sql @@ -0,0 +1,5 @@ +select row_number() over (order by ar1.stratum_1) as concept_id, + ar1.stratum_1 as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 +where ar1.analysis_id = 113 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/person/ethnicity.sql b/src/main/resources/resources/cdmresults/sql/report/person/ethnicity.sql new file mode 100644 index 0000000000..f6723341d0 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/person/ethnicity.sql @@ -0,0 +1,8 @@ +select c1.concept_id as concept_id, + c1.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join + @vocab_database_schema.concept c1 + on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) +where ar1.analysis_id = 5 diff --git a/src/main/resources/resources/cdmresults/sql/report/person/gender.sql b/src/main/resources/resources/cdmresults/sql/report/person/gender.sql new file mode 100644 index 0000000000..f1587df99f --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/person/gender.sql @@ -0,0 +1,9 @@ +select c1.concept_id as concept_id, + c1.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join + @vocab_database_schema.concept c1 + on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) +where ar1.analysis_id = 2 +and c1.concept_id in (8507, 8532) \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/person/population.sql b/src/main/resources/resources/cdmresults/sql/report/person/population.sql new file mode 100644 index 0000000000..62824ad453 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/person/population.sql @@ -0,0 +1,19 @@ +(select aa1.analysis_name as attribute_name, + ar1.stratum_1 as attribute_value +from @results_database_schema.ACHILLES_analysis aa1 +inner join +@results_database_schema.ACHILLES_results ar1 +on aa1.analysis_id = ar1.analysis_id +where aa1.analysis_id = 0 + +union + +select aa1.analysis_name as attribute_name, +cast(ar1.count_value as varchar) as attribute_value +from @results_database_schema.ACHILLES_analysis aa1 +inner join +@results_database_schema.ACHILLES_results ar1 +on aa1.analysis_id = ar1.analysis_id +where aa1.analysis_id = 1 +) +order by attribute_name desc diff --git a/src/main/resources/resources/cdmresults/sql/report/person/race.sql b/src/main/resources/resources/cdmresults/sql/report/person/race.sql new file mode 100644 index 0000000000..d4fb85c52e --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/person/race.sql @@ -0,0 +1,8 @@ +select c1.concept_id as concept_id, + c1.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join + @vocab_database_schema.concept c1 + on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) +where ar1.analysis_id = 4 diff --git a/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_data.sql b/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_data.sql new file mode 100644 index 0000000000..c70069eec4 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_data.sql @@ -0,0 +1,7 @@ +select cast(ar1.stratum_1 as int) - MinValue.MinValue as interval_index, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 3) ar1, + (select min(cast(stratum_1 as int)) as MinValue from @results_database_schema.ACHILLES_results where analysis_id = 3) MinValue, + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom +order by ar1.stratum_1 asc diff --git a/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_stats.sql b/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_stats.sql new file mode 100644 index 0000000000..63da3ee20d --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_stats.sql @@ -0,0 +1,5 @@ +select min(cast(ar1.stratum_1 as int)) as min_value, + max(cast(ar1.stratum_1 as int)) as max_value, + 1 as interval_size +from @results_database_schema.ACHILLES_results ar1 +where ar1.analysis_id = 3 diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/sqlAgeAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/report/procedure/sqlAgeAtFirstOccurrence.sql new file mode 100644 index 0000000000..225aa32251 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/procedure/sqlAgeAtFirstOccurrence.sql @@ -0,0 +1,17 @@ + select c1.concept_id as concept_id, + c2.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join + @vocab_database_schema.concept c1 + on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join + @vocab_database_schema.concept c2 + on ard1.stratum_2 = CAST(c2.concept_id as VARCHAR) +where ard1.analysis_id = 606 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/procedure/sqlPrevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..8bd3528915 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/procedure/sqlPrevalenceByGenderAgeYear.sql @@ -0,0 +1,33 @@ +SELECT c1.concept_id AS concept_id, + c1.concept_name as concept_name, + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS VARCHAR) AS trellis_name, --age decile + c2.concept_name AS series_name, --gender + num_stratum_2 AS x_calendar_year, -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), 5) AS y_prevalence_1000pp --prevalence, per 1000 persons +FROM ( + SELECT num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 604 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp +INNER JOIN @vocab_database_schema.concept c1 + ON num_stratum_1 = CAST(c1.concept_id as VARCHAR) +INNER JOIN @vocab_database_schema.concept c2 + ON num_stratum_3 = CAST(c2.concept_id as VARCHAR) diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/procedure/sqlPrevalenceByMonth.sql new file mode 100644 index 0000000000..2e39fb8128 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/procedure/sqlPrevalenceByMonth.sql @@ -0,0 +1,11 @@ + select c1.concept_id as concept_id, + c1.concept_name as concept_name, + num.stratum_2 as x_calendar_month, -- calendar year, note, there could be blanks + round(1000*(1.0*num.count_value/denom.count_value),5) as y_prevalence_1000pp --prevalence, per 1000 persons +from + (select * from @results_database_schema.ACHILLES_results where analysis_id = 602) num + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 117) + denom on num.stratum_2 = denom.stratum_1 --calendar year + inner join @vocab_database_schema.concept c1 on num.stratum_1 = CAST(c1.concept_id as VARCHAR) +ORDER BY CAST(num.stratum_2 as INT) diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/sqlProcedureTreemap.sql b/src/main/resources/resources/cdmresults/sql/report/procedure/sqlProcedureTreemap.sql new file mode 100644 index 0000000000..3aaf512dd9 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/procedure/sqlProcedureTreemap.sql @@ -0,0 +1,117 @@ +select concept_hierarchy.concept_id, + isNull(concept_hierarchy.level4_concept_name,'NA') + + '||' + isNull(concept_hierarchy.level3_concept_name,'NA') + + '||' + isNull(concept_hierarchy.level2_concept_name,'NA') + + '||' + isNull(concept_hierarchy.proc_concept_name,'NA') concept_path, + ar1.count_value as num_persons, + 1.0*ar1.count_value / denom.count_value as percent_persons, + 1.0*ar2.count_value / ar1.count_value as records_per_person +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 600) ar1 + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 601) ar2 + on ar1.stratum_1 = ar2.stratum_1 + inner join + ( + select procs.concept_id, + procs.proc_concept_name, + max(proc_hierarchy.os3_concept_name) as level2_concept_name, + max(proc_hierarchy.os2_concept_name) as level3_concept_name, + max(proc_hierarchy.os1_concept_name) as level4_concept_name + from + ( + select c1.concept_id, + v1.vocabulary_name + ' ' + c1.concept_code + ': ' + c1.concept_name as proc_concept_name + from @vocab_database_schema.concept c1 + inner join @vocab_database_schema.vocabulary v1 + on c1.vocabulary_id = v1.vocabulary_id + WHERE c1.domain_id = 'Procedure' + ) procs + left join + (select ca0.DESCENDANT_CONCEPT_ID, max(ca0.ancestor_concept_id) as ancestor_concept_id + from @vocab_database_schema.concept_ancestor ca0 + inner join + (select distinct c2.concept_id as os3_concept_id + from @vocab_database_schema.concept_ancestor ca1 + inner join + @vocab_database_schema.concept c1 + on ca1.DESCENDANT_CONCEPT_ID = c1.concept_id + inner join + @vocab_database_schema.concept_ancestor ca2 + on c1.concept_id = ca2.ANCESTOR_CONCEPT_ID + inner join + @vocab_database_schema.concept c2 + on ca2.DESCENDANT_CONCEPT_ID = c2.concept_id + where ca1.ancestor_concept_id = 4040390 + and ca1.Min_LEVELS_OF_SEPARATION = 2 + and ca2.MIN_LEVELS_OF_SEPARATION = 1 + ) t1 + + on ca0.ANCESTOR_CONCEPT_ID = t1.os3_concept_id + + group by ca0.descendant_concept_id + + ) ca1 + on procs.concept_id = ca1.DESCENDANT_CONCEPT_ID + left join + ( + select proc_by_os1.os1_concept_name, + proc_by_os2.os2_concept_name, + proc_by_os3.os3_concept_name, + proc_by_os3.os3_concept_id + from + (select DESCENDANT_CONCEPT_ID as os1_concept_id, concept_name as os1_concept_name + from @vocab_database_schema.concept_ancestor ca1 + inner join + @vocab_database_schema.concept c1 + on ca1.DESCENDANT_CONCEPT_ID = c1.concept_id + where ancestor_concept_id = 4040390 + and Min_LEVELS_OF_SEPARATION = 1 + ) proc_by_os1 + + inner join + (select max(c1.CONCEPT_ID) as os1_concept_id, c2.concept_id as os2_concept_id, c2.concept_name as os2_concept_name + from @vocab_database_schema.concept_ancestor ca1 + inner join + @vocab_database_schema.concept c1 + on ca1.DESCENDANT_CONCEPT_ID = c1.concept_id + inner join + @vocab_database_schema.concept_ancestor ca2 + on c1.concept_id = ca2.ANCESTOR_CONCEPT_ID + inner join + @vocab_database_schema.concept c2 + on ca2.DESCENDANT_CONCEPT_ID = c2.concept_id + where ca1.ancestor_concept_id = 4040390 + and ca1.Min_LEVELS_OF_SEPARATION = 1 + and ca2.MIN_LEVELS_OF_SEPARATION = 1 + group by c2.concept_id, c2.concept_name + ) proc_by_os2 + on proc_by_os1.os1_concept_id = proc_by_os2.os1_concept_id + + inner join + (select max(c1.CONCEPT_ID) as os2_concept_id, c2.concept_id as os3_concept_id, c2.concept_name as os3_concept_name + from @vocab_database_schema.concept_ancestor ca1 + inner join + @vocab_database_schema.concept c1 + on ca1.DESCENDANT_CONCEPT_ID = c1.concept_id + inner join + @vocab_database_schema.concept_ancestor ca2 + on c1.concept_id = ca2.ANCESTOR_CONCEPT_ID + inner join + @vocab_database_schema.concept c2 + on ca2.DESCENDANT_CONCEPT_ID = c2.concept_id + where ca1.ancestor_concept_id = 4040390 + and ca1.Min_LEVELS_OF_SEPARATION = 2 + and ca2.MIN_LEVELS_OF_SEPARATION = 1 + group by c2.concept_id, c2.concept_name + ) proc_by_os3 + on proc_by_os2.os2_concept_id = proc_by_os3.os2_concept_id + ) proc_hierarchy + on ca1.ancestor_concept_id = proc_hierarchy.os3_concept_id + group by procs.concept_id, + procs.proc_concept_name + + ) concept_hierarchy + on ar1.stratum_1 = CAST(concept_hierarchy.concept_id as VARCHAR) + , + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom + diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/sqlProceduresByType.sql b/src/main/resources/resources/cdmresults/sql/report/procedure/sqlProceduresByType.sql new file mode 100644 index 0000000000..2a9de4bde8 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/procedure/sqlProceduresByType.sql @@ -0,0 +1,9 @@ +select c1.concept_id as procedure_concept_id, + c1.concept_name as procedure_concept_name, + c2.concept_id as concept_id, + c2.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join @vocab_database_schema.concept c1 on ar1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join @vocab_database_schema.concept c2 on ar1.stratum_2 = CAST(c2.concept_id as VARCHAR) +where ar1.analysis_id = 605 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/sqlAgeAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/report/visit/sqlAgeAtFirstOccurrence.sql new file mode 100644 index 0000000000..98d195789f --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/visit/sqlAgeAtFirstOccurrence.sql @@ -0,0 +1,13 @@ +select c1.concept_id as concept_id, + c2.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) + inner join @vocab_database_schema.concept c2 on ard1.stratum_2 = CAST(c2.concept_id as VARCHAR) +where ard1.analysis_id = 206 diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/visit/sqlPrevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..31c488bd7a --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/visit/sqlPrevalenceByGenderAgeYear.sql @@ -0,0 +1,35 @@ +SELECT c1.concept_id AS concept_id, + c1.concept_name as concept_name, + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS VARCHAR) AS trellis_name, --age decile + c2.concept_name AS series_name, --gender + num_stratum_2 AS x_calendar_year, -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), 5) AS y_prevalence_1000pp --prevalence, per 1000 persons +FROM ( + SELECT num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 204 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp +INNER JOIN @vocab_database_schema.concept c1 + ON num_stratum_1 = CAST(c1.concept_id as VARCHAR) +INNER JOIN @vocab_database_schema.concept c2 + ON num_stratum_3 = CAST(c2.concept_id as VARCHAR) + + diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/visit/sqlPrevalenceByMonth.sql new file mode 100644 index 0000000000..c9b95a7be6 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/visit/sqlPrevalenceByMonth.sql @@ -0,0 +1,10 @@ +select c1.concept_id as concept_id, --all rows for all concepts, but you may split by conceptid + c1.concept_name as concept_name, + num.stratum_2 as x_calendar_month, -- calendar year, note, there could be blanks + 1000*(1.0*num.count_value/denom.count_value) as y_prevalence_1000pp --prevalence, per 1000 persons +from + (select * from @results_database_schema.ACHILLES_results where analysis_id = 202) num + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom on num.stratum_2 = denom.stratum_1 --calendar year + inner join @vocab_database_schema.concept c1 on num.stratum_1 = CAST(c1.concept_id as VARCHAR) + diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/sqlVisitDurationByType.sql b/src/main/resources/resources/cdmresults/sql/report/visit/sqlVisitDurationByType.sql new file mode 100644 index 0000000000..d617adc47e --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/visit/sqlVisitDurationByType.sql @@ -0,0 +1,13 @@ +select c1.concept_id as concept_id, + 'Length of stay' as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join + @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) +where ard1.analysis_id = 211 diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/sqlVisitTreemap.sql b/src/main/resources/resources/cdmresults/sql/report/visit/sqlVisitTreemap.sql new file mode 100644 index 0000000000..eeb330315a --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/visit/sqlVisitTreemap.sql @@ -0,0 +1,11 @@ +select c1.concept_id, + c1.concept_name as concept_path, + ar1.count_value as num_persons, + 1.0*ar1.count_value / denom.count_value as percent_persons, + 1.0*ar2.count_value / ar1.count_value as records_per_person +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 200) ar1 + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 201) ar2 on ar1.stratum_1 = ar2.stratum_1 + inner join @vocab_database_schema.concept c1 on ar1.stratum_1 = CAST(c1.concept_id as VARCHAR), + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom + diff --git a/src/main/resources/resources/observationperiod/sql/ageatfirst.sql b/src/main/resources/resources/observationperiod/sql/ageatfirst.sql new file mode 100644 index 0000000000..00956a3c6e --- /dev/null +++ b/src/main/resources/resources/observationperiod/sql/ageatfirst.sql @@ -0,0 +1,10 @@ +select cast(ar1.stratum_1 as int) as interval_index, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from +( + select * from @results_database_schema.ACHILLES_results where analysis_id = 101 +) ar1, +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom \ No newline at end of file diff --git a/src/main/resources/resources/observationperiod/sql/agebygender.sql b/src/main/resources/resources/observationperiod/sql/agebygender.sql new file mode 100644 index 0000000000..66992b463d --- /dev/null +++ b/src/main/resources/resources/observationperiod/sql/agebygender.sql @@ -0,0 +1,11 @@ +select c1.concept_name as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) +where ard1.analysis_id = 104 \ No newline at end of file diff --git a/src/main/resources/resources/observationperiod/sql/cumulativeduration.sql b/src/main/resources/resources/observationperiod/sql/cumulativeduration.sql new file mode 100644 index 0000000000..7542e49c47 --- /dev/null +++ b/src/main/resources/resources/observationperiod/sql/cumulativeduration.sql @@ -0,0 +1,13 @@ +select 'Length of observation' as series_name, + cast(ar1.stratum_1 as int)*30 as x_length_of_observation, + round(1.0*sum(ar2.count_value) / denom.count_value,5) as y_percent_persons +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 108) ar1 +inner join +( + select * from @results_database_schema.ACHILLES_results where analysis_id = 108 +) ar2 on ar1.analysis_id = ar2.analysis_id and cast(ar1.stratum_1 as int) <= cast(ar2.stratum_1 as int), +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom +group by cast(ar1.stratum_1 as int)*30, denom.count_value +order by cast(ar1.stratum_1 as int)*30 asc diff --git a/src/main/resources/resources/observationperiod/sql/observationlength_data.sql b/src/main/resources/resources/observationperiod/sql/observationlength_data.sql new file mode 100644 index 0000000000..ca38aba3a3 --- /dev/null +++ b/src/main/resources/resources/observationperiod/sql/observationlength_data.sql @@ -0,0 +1,9 @@ +select cast(ar1.stratum_1 as int) as interval_index, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from @results_database_schema.ACHILLES_analysis aa1 +inner join @results_database_schema.ACHILLES_results ar1 on aa1.analysis_id = ar1.analysis_id, +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom +where aa1.analysis_id = 108 diff --git a/src/main/resources/resources/observationperiod/sql/observationlength_stats.sql b/src/main/resources/resources/observationperiod/sql/observationlength_stats.sql new file mode 100644 index 0000000000..52f311c927 --- /dev/null +++ b/src/main/resources/resources/observationperiod/sql/observationlength_stats.sql @@ -0,0 +1,9 @@ +select min(cast(ar1.stratum_1 as int)) * 30 as min_value, + max(cast(ar1.stratum_1 as int)) * 30 as max_value, + 30 as interval_size +from @results_database_schema.ACHILLES_analysis aa1 +inner join @results_database_schema.ACHILLES_results ar1 on aa1.analysis_id = ar1.analysis_id, +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom +where aa1.analysis_id = 108 \ No newline at end of file diff --git a/src/main/resources/resources/observationperiod/sql/observationlengthbyage.sql b/src/main/resources/resources/observationperiod/sql/observationlengthbyage.sql new file mode 100644 index 0000000000..f69160bcae --- /dev/null +++ b/src/main/resources/resources/observationperiod/sql/observationlengthbyage.sql @@ -0,0 +1,10 @@ + select cast(cast(ard1.stratum_1 as int)*10 as varchar) + '-' + cast((cast(ard1.stratum_1 as int)+1)*10-1 as varchar) as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 107 diff --git a/src/main/resources/resources/observationperiod/sql/observationlengthbygender.sql b/src/main/resources/resources/observationperiod/sql/observationlengthbygender.sql new file mode 100644 index 0000000000..1383c2bb88 --- /dev/null +++ b/src/main/resources/resources/observationperiod/sql/observationlengthbygender.sql @@ -0,0 +1,11 @@ +select c1.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) +where ard1.analysis_id = 106 \ No newline at end of file diff --git a/src/main/resources/resources/observationperiod/sql/observedbymonth.sql b/src/main/resources/resources/observationperiod/sql/observedbymonth.sql new file mode 100644 index 0000000000..f4143f1c7f --- /dev/null +++ b/src/main/resources/resources/observationperiod/sql/observedbymonth.sql @@ -0,0 +1,7 @@ +select cast(ar1.stratum_1 as int) as month_year, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 110) ar1, + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom + + \ No newline at end of file diff --git a/src/main/resources/resources/observationperiod/sql/observedbyyear_data.sql b/src/main/resources/resources/observationperiod/sql/observedbyyear_data.sql new file mode 100644 index 0000000000..084ac45880 --- /dev/null +++ b/src/main/resources/resources/observationperiod/sql/observedbyyear_data.sql @@ -0,0 +1,14 @@ +select cast(ar1.stratum_1 as int) - MinValue.MinValue as interval_index, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from +( + select * from @results_database_schema.ACHILLES_results where analysis_id = 109 +) ar1, +( + select min(cast(stratum_1 as int)) as MinValue + from @results_database_schema.ACHILLES_results where analysis_id = 109 +) MinValue, +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom \ No newline at end of file diff --git a/src/main/resources/resources/observationperiod/sql/observedbyyear_stats.sql b/src/main/resources/resources/observationperiod/sql/observedbyyear_stats.sql new file mode 100644 index 0000000000..048971af81 --- /dev/null +++ b/src/main/resources/resources/observationperiod/sql/observedbyyear_stats.sql @@ -0,0 +1,5 @@ +select min(cast(ar1.stratum_1 as int)) as min_value, + max(cast(ar1.stratum_1 as int)) as max_value, + 1 as interval_size +from @results_database_schema.ACHILLES_results ar1 +where ar1.analysis_id = 109 \ No newline at end of file diff --git a/src/main/resources/resources/observationperiod/sql/periodsperperson.sql b/src/main/resources/resources/observationperiod/sql/periodsperperson.sql new file mode 100644 index 0000000000..67d048940d --- /dev/null +++ b/src/main/resources/resources/observationperiod/sql/periodsperperson.sql @@ -0,0 +1,5 @@ +select row_number() over (order by ar1.stratum_1) as concept_id, + ar1.stratum_1 as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 +where ar1.analysis_id = 113 \ No newline at end of file diff --git a/src/main/resources/resources/person/sql/ethnicity.sql b/src/main/resources/resources/person/sql/ethnicity.sql new file mode 100644 index 0000000000..1ce6058b37 --- /dev/null +++ b/src/main/resources/resources/person/sql/ethnicity.sql @@ -0,0 +1,9 @@ +-- noinspection SqlDialectInspectionForFile +select c1.concept_id as concept_id, + c1.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join + @vocab_database_schema.concept c1 + on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) +where ar1.analysis_id = 5 \ No newline at end of file diff --git a/src/main/resources/resources/person/sql/gender.sql b/src/main/resources/resources/person/sql/gender.sql new file mode 100644 index 0000000000..5aee8d8380 --- /dev/null +++ b/src/main/resources/resources/person/sql/gender.sql @@ -0,0 +1,9 @@ +select c1.concept_id as concept_id, + c1.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join + @vocab_database_schema.concept c1 + on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) +where ar1.analysis_id = 2 +and c1.concept_id in (8507, 8532) \ No newline at end of file diff --git a/src/main/resources/resources/person/sql/population.sql b/src/main/resources/resources/person/sql/population.sql new file mode 100644 index 0000000000..9b8a7c82e2 --- /dev/null +++ b/src/main/resources/resources/person/sql/population.sql @@ -0,0 +1,19 @@ +(select aa1.analysis_name as attribute_name, + ar1.stratum_1 as attribute_value +from @results_database_schema.ACHILLES_analysis aa1 +inner join +@results_database_schema.ACHILLES_results ar1 +on aa1.analysis_id = ar1.analysis_id +where aa1.analysis_id = 0 + +union + +select aa1.analysis_name as attribute_name, +cast(ar1.count_value as varchar) as attribute_value +from @results_database_schema.ACHILLES_analysis aa1 +inner join +@results_database_schema.ACHILLES_results ar1 +on aa1.analysis_id = ar1.analysis_id +where aa1.analysis_id = 1 +) +order by attribute_name desc \ No newline at end of file diff --git a/src/main/resources/resources/person/sql/race.sql b/src/main/resources/resources/person/sql/race.sql new file mode 100644 index 0000000000..12c9ab3395 --- /dev/null +++ b/src/main/resources/resources/person/sql/race.sql @@ -0,0 +1,8 @@ +select c1.concept_id as concept_id, + c1.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join + @vocab_database_schema.concept c1 + on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) +where ar1.analysis_id = 4 \ No newline at end of file diff --git a/src/main/resources/resources/person/sql/yearofbirth_data.sql b/src/main/resources/resources/person/sql/yearofbirth_data.sql new file mode 100644 index 0000000000..c70069eec4 --- /dev/null +++ b/src/main/resources/resources/person/sql/yearofbirth_data.sql @@ -0,0 +1,7 @@ +select cast(ar1.stratum_1 as int) - MinValue.MinValue as interval_index, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 3) ar1, + (select min(cast(stratum_1 as int)) as MinValue from @results_database_schema.ACHILLES_results where analysis_id = 3) MinValue, + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom +order by ar1.stratum_1 asc diff --git a/src/main/resources/resources/person/sql/yearofbirth_stats.sql b/src/main/resources/resources/person/sql/yearofbirth_stats.sql new file mode 100644 index 0000000000..63da3ee20d --- /dev/null +++ b/src/main/resources/resources/person/sql/yearofbirth_stats.sql @@ -0,0 +1,5 @@ +select min(cast(ar1.stratum_1 as int)) as min_value, + max(cast(ar1.stratum_1 as int)) as max_value, + 1 as interval_size +from @results_database_schema.ACHILLES_results ar1 +where ar1.analysis_id = 3 diff --git a/src/test/java/org/ohdsi/webapi/test/CharacterizationServiceIT.java b/src/test/java/org/ohdsi/webapi/test/CharacterizationServiceIT.java new file mode 100644 index 0000000000..9492812d3f --- /dev/null +++ b/src/test/java/org/ohdsi/webapi/test/CharacterizationServiceIT.java @@ -0,0 +1,60 @@ +package org.ohdsi.webapi.test; + +import org.junit.Test; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.util.Assert; + +/** + * Test related to characterization services + */ +public class CharacterizationServiceIT extends WebApiIT { + + public static final String NYP_COLUMBIA5_54_DEID = "NYP-Columbia5.4-deid"; + + public static String TEST_DATASOURCES = "{ \"datasources\": [ { \"name\":\"NYP-Columbia5.4-deid\", \"folder\":\"ohdsi_deid\" , \"cdmVersion\":5} ] }"; + + public static String TEST_DASHBOARD = "{\"SUMMARY\":{\"ATTRIBUTE_NAME\":[\"Source name\",\"Number of persons\"],\"ATTRIBUTE_VALUE\":[\"NYP-Columbia5.4-deid\",\"5111022\"]},\"GENDER_DATA\":{\"CONCEPT_ID\":[8507,8532],\"CONCEPT_NAME\":[\"MALE\",\"FEMALE\"],\"COUNT_VALUE\":[2244526,2854071]},\"AGE_AT_FIRST_OBSERVATION_HISTOGRAM\":{\"MIN\":0,\"MAX\":100,\"INTERVAL_SIZE\":1,\"INTERVALS\":100,\"DATA\":{\"INTERVAL_INDEX\":[221,26,87,219,19,228,85,62,53,17,226,60,28,51,0,215,232,-16,15,66,32,49,230,81,64,47,30,13,217,83,23,6,55,38,24,224,41,73,5,-6,56,223,74,-7,69,3,-2,212,235,78,12,35,67,44,1,210,-11,10,42,76,-9,71,-4,237,37,-22,75,72,-5,21,58,-8,7,239,25,22,222,225,39,40,57,8,46,63,50,216,233,65,231,82,33,16,-15,48,31,214,80,14,29,218,229,86,43,236,18,61,4,211,79,36,11,54,68,-1,238,9,52,213,27,70,84,227,234,59,45,2,-3,77,-10,34,220,20],\"COUNT_VALUE\":[6688,45565,125,7369,31982,3386,801,17293,23633,26672,3209,18970,44637,24321,231179,15012,2495,13,23904,14350,40452,24942,3046,2254,14921,25211,43308,20477,9421,1526,43950,22656,22622,32129,45382,5139,29985,7228,24275,18,21962,5478,6522,28,11063,30456,76,7920,1809,3980,20736,36596,13073,27218,63125,15437,7,18473,28895,5052,15,8785,28,1551,33867,10,5967,8047,24,37223,20961,21,20583,1392,45558,40621,6218,4111,31315,30867,21573,18887,25985,16550,25074,12955,2025,14793,2673,1922,39344,24787,13,25627,42386,9652,2813,22016,44389,8133,3516,444,28194,1657,28923,18218,26517,11117,3294,35299,19545,22838,12193,190,1378,18746,23983,9209,45125,9729,1072,3502,1920,20041,26384,39615,68,4669,11,37906,7275,34725],\"PERCENT_VALUE\":[0.00131,0.00892,2e-005,0.00144,0.00626,0.00066,0.00016,0.00338,0.00462,0.00522,0.00063,0.00371,0.00873,0.00476,0.04523,0.00294,0.00049,0,0.00468,0.00281,0.00791,0.00488,0.0006,0.00044,0.00292,0.00493,0.00847,0.00401,0.00184,0.0003,0.0086,0.00443,0.00443,0.00629,0.00888,0.00101,0.00587,0.00141,0.00475,0,0.0043,0.00107,0.00128,1e-005,0.00216,0.00596,1e-005,0.00155,0.00035,0.00078,0.00406,0.00716,0.00256,0.00533,0.01235,0.00302,0,0.00361,0.00565,0.00099,0,0.00172,1e-005,0.0003,0.00663,0,0.00117,0.00157,0,0.00728,0.0041,0,0.00403,0.00027,0.00891,0.00795,0.00122,0.0008,0.00613,0.00604,0.00422,0.0037,0.00508,0.00324,0.00491,0.00253,0.0004,0.00289,0.00052,0.00038,0.0077,0.00485,0,0.00501,0.00829,0.00189,0.00055,0.00431,0.00868,0.00159,0.00069,9e-005,0.00552,0.00032,0.00566,0.00356,0.00519,0.00218,0.00064,0.00691,0.00382,0.00447,0.00239,4e-005,0.00027,0.00367,0.00469,0.0018,0.00883,0.0019,0.00021,0.00069,0.00038,0.00392,0.00516,0.00775,1e-005,0.00091,0,0.00742,0.00142,0.00679]}},\"CUMULATIVE_DURATION\":{\"SERIES_NAME\":[\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\"],\"X_LENGTH_OF_OBSERVATION\":[0,30,60,90,120,150,180,210,240,270,300,330,360,390,420,450,480,510,540,570,600,630,660,690,720,750,780,810,840,870,900,930,960,990,1020,1050,1080,1110,1140,1170,1200,1230,1260,1290,1320,1350,1380,1410,1440,1470,1500,1530,1560,1590,1620,1650,1680,1710,1740,1770,1800,1830,1860,1890,1920,1950,1980,2010,2040,2070,2100,2130,2160,2190,2220,2250,2280,2310,2340,2370,2400,2430,2460,2490,2520,2550,2580,2610,2640,2670,2700,2730,2760,2790,2820,2850,2880,2910,2940,2970,3000,3030,3060,3090,3120,3150,3180,3210,3240,3270,3300,3330,3360,3390,3420,3450,3480,3510,3540,3570,3600,3630,3660,3690,3720,3750,3780,3810,3840,3870,3900,3930,3960,3990,4020,4050,4080,4110,4140,4170,4200,4230,4260,4290,4320,4350,4380,4410,4440,4470,4500,4530,4560,4590,4620,4650,4680,4710,4740,4770,4800,4830,4860,4890,4920,4950,4980,5010,5040,5070,5100,5130,5160,5190,5220,5250,5280,5310,5340,5370,5400,5430,5460,5490,5520,5550,5580,5610,5640,5670,5700,5730,5760,5790,5820,5850,5880,5910,5940,5970,6000,6030,6060,6090,6120,6150,6180,6210,6240,6270,6300,6330,6360,6390,6420,6450,6480,6510,6540,6570,6600,6630,6660,6690,6720,6750,6780,6810,6840,6870,6900,6930,6960,6990,7020,7050,7080,7110,7140,7170,7200,7230,7260,7290,7320,7350,7380,7410,7440,7470,7500,7530,7560,7590,7620,7650,7680,7710,7740,7770,7800,7830,7860,7890,7920,7950,7980,8010,8040,8070,8100,8130,8160,8190,8220,8250,8280,8310,8340,8370,8400,8430,8460,8490,8520,8550,8580,8610,8640,8670,8700,8730,8760,8790,8820,8850,8880,8910,8940,8970,9000,9030,9060,9090,9120,9150,9180,9210,9240,9270,9300,9330,9360,9390,9420,9450,9480,9510,9540,9570,9600,9630,9660,9690,9720,9750,9780,9810,9840,9870,9900,9930,9960,9990,10020,10050,10080,10110,10140,10170,10200,10230,10260,10290,10320,10350,10380,10410,10440,10470,10500,10530,10560,10590,10620,10650,10680,10710,10740,10770,10800,10830,10860,10890,10920],\"Y_PERCENT_PERSONS\":[0.4561,0.24656,0.23307,0.22473,0.21832,0.21314,0.20867,0.20418,0.20004,0.19651,0.19324,0.19022,0.18722,0.18378,0.18087,0.17817,0.17564,0.17327,0.17096,0.16868,0.16655,0.16448,0.16247,0.16051,0.1585,0.1563,0.15429,0.15244,0.15065,0.14888,0.14723,0.14555,0.14393,0.14236,0.14087,0.13936,0.13782,0.13627,0.13476,0.13328,0.13192,0.13058,0.1293,0.12798,0.1267,0.12545,0.12423,0.12303,0.12187,0.12063,0.11937,0.11819,0.11704,0.11592,0.11482,0.11373,0.11266,0.11158,0.11058,0.10958,0.10855,0.10749,0.10646,0.10542,0.10442,0.10345,0.10251,0.10155,0.1006,0.09969,0.09881,0.09793,0.09709,0.09625,0.09536,0.09455,0.09373,0.09292,0.0921,0.09131,0.09055,0.08977,0.08902,0.08827,0.08753,0.08677,0.08601,0.08527,0.08455,0.08382,0.08312,0.08244,0.08175,0.08108,0.08038,0.07971,0.07907,0.07842,0.07774,0.07708,0.07644,0.07581,0.07518,0.07454,0.07392,0.07332,0.07271,0.07211,0.07152,0.07095,0.07034,0.06975,0.06915,0.06858,0.06802,0.06746,0.0669,0.06635,0.06582,0.06528,0.06476,0.06424,0.0637,0.06318,0.06264,0.06212,0.06162,0.0611,0.06059,0.06009,0.05958,0.0591,0.05862,0.05813,0.05764,0.05713,0.05665,0.05616,0.0557,0.05524,0.05477,0.0543,0.05383,0.05338,0.05292,0.05246,0.05201,0.05156,0.0511,0.05065,0.05022,0.04979,0.04936,0.04896,0.04856,0.04815,0.04774,0.04733,0.04692,0.04652,0.04611,0.04572,0.04533,0.04494,0.04453,0.04413,0.04372,0.04335,0.04297,0.04259,0.04221,0.04184,0.04146,0.04109,0.04072,0.04035,0.04,0.03965,0.0393,0.03895,0.03859,0.03825,0.03789,0.03754,0.03719,0.03685,0.03651,0.03618,0.03585,0.03551,0.03519,0.03486,0.03455,0.03423,0.03391,0.03359,0.03328,0.03295,0.03262,0.03231,0.032,0.0317,0.03139,0.03108,0.03078,0.03047,0.03015,0.02984,0.02954,0.02925,0.02895,0.02865,0.02835,0.02804,0.02774,0.02744,0.02716,0.02688,0.02659,0.0263,0.02603,0.02575,0.02546,0.02519,0.02493,0.02466,0.02439,0.02413,0.02387,0.0236,0.02334,0.02307,0.02281,0.02255,0.02229,0.02205,0.02181,0.02156,0.02131,0.02106,0.02083,0.02059,0.02035,0.02012,0.01988,0.01965,0.01942,0.01919,0.01897,0.01876,0.01855,0.01834,0.0181,0.01787,0.01763,0.01741,0.01718,0.01696,0.01675,0.01653,0.01633,0.01612,0.01589,0.01569,0.01548,0.01527,0.01506,0.01485,0.01465,0.01444,0.01422,0.01401,0.0138,0.01359,0.01339,0.01318,0.01298,0.01278,0.01258,0.01237,0.01216,0.01196,0.01175,0.01155,0.01135,0.01115,0.01095,0.01075,0.01056,0.01035,0.01015,0.00996,0.00975,0.00956,0.00937,0.00917,0.00897,0.00878,0.00859,0.00841,0.00824,0.00806,0.0079,0.00775,0.00759,0.00744,0.00728,0.00712,0.00697,0.00681,0.00666,0.00651,0.00637,0.00623,0.00607,0.00593,0.00578,0.00564,0.0055,0.00537,0.00522,0.00508,0.00495,0.00481,0.00467,0.00455,0.00442,0.0043,0.00416,0.00404,0.0039,0.00377,0.00364,0.00352,0.00339,0.00326,0.00313,0.003,0.00286,0.00273,0.0026,0.00248,0.00236,0.00222,0.00209,0.00197,0.00184,0.00171,0.00159,0.00145,0.00131,0.00118,0.00105,0.00091,0.00078,0.00066,0.00054,0.00043,0.00033,0.00025,0.00018,0.00011,7e-005,3e-005,1e-005]},\"OBSERVED_BY_MONTH\":{\"MONTH_YEAR\":[198608,198610,198708,198710,198808,198810,198908,198910,199008,199010,199012,199110,199112,199210,199212,199310,199312,199410,199412,199510,199512,199610,199612,199710,199712,199812,199912,200012,200112,200212,200312,200412,200512,201101,201201,201301,201401,201501,198611,198803,198903,199003,199103,199203,199204,199303,199304,199403,199404,199503,199504,199603,199604,199703,199704,199803,199804,199903,199904,200003,200004,200103,200104,200203,200204,200304,200307,200404,200407,200504,200507,200604,200607,200608,200707,200708,200807,200808,200907,200908,201007,201008,201107,201108,201207,201208,201307,201308,201407,201408,201507,201508,198604,198606,198704,198706,198804,198806,198904,198906,199004,199006,199104,199106,199108,199206,199208,199306,199308,199406,199408,199506,199508,199601,199606,199608,199701,199706,199708,199801,199806,199808,199810,199901,199908,199910,200001,200008,200010,200101,200108,200110,200201,200208,200210,200301,200303,200308,200310,200401,200403,200408,200410,200501,200503,200508,200510,200601,200603,200610,200612,200701,200703,200710,200712,200801,200803,200810,200812,200901,200903,200910,200912,201001,201003,201005,201010,201012,201103,201105,201110,201112,201203,201205,201210,201212,201303,201305,201312,201403,201405,201412,201503,201505,201512,198607,198609,198709,198711,198809,198811,198909,198911,199009,199011,199109,199111,199209,199211,199309,199311,199409,199411,199511,199611,199711,199811,199911,200011,200111,201502,198605,198612,198705,198712,198805,198812,198905,198912,199005,199105,199205,199305,199405,199509,199609,199709,199809,199909,200002,200009,200102,200109,200202,200209,200302,200309,200402,200409,200502,200509,200602,200609,200702,200709,200802,200809,200902,200909,201002,201102,201202,201302,201402,201406,201506,198602,198701,198702,198801,198802,198901,198902,199001,199002,199101,199102,199201,199202,199301,199302,199401,199402,199501,199502,199505,199602,199605,199702,199705,199802,199805,199902,199905,199906,200005,200006,200105,200106,200205,200206,200305,200306,200405,200406,200505,200506,200605,200606,200705,200706,200805,200806,200905,200906,201006,201009,201106,201109,201206,201209,201306,201309,201310,201409,201410,201509,201510,198603,198703,198707,198807,198907,199007,199107,199207,199307,199407,199507,199607,199707,199807,199907,200007,200107,200207,200211,200311,200411,200511,200611,200704,200711,200804,200811,200904,200911,201004,201011,201104,201111,201204,201211,201304,201311,201404,201411,201504,201511],\"COUNT_VALUE\":[32413,45943,98340,104821,130659,135067,155603,159853,179771,183354,187062,211646,216928,236224,239054,252229,254525,265837,267794,277855,279923,292794,295488,307576,309653,321787,333393,339806,345053,356381,367214,376976,382358,355800,335338,309885,273346,210036,53222,118694,145309,170093,193642,223755,226010,243185,244652,257901,259116,270793,271914,283438,284743,299674,301136,312814,313872,325036,326133,335380,336022,340878,341314,347479,348531,359825,362667,370723,373107,379481,380792,382845,382682,382620,380424,380235,377491,377114,372763,372126,362960,361707,346592,344918,323487,321207,293690,290551,247877,242545,145357,128739,10129,20275,82961,91256,121282,126220,147438,151507,172102,175911,196153,201336,206507,229665,233035,247286,249734,261386,263596,274040,275917,281026,287287,290037,297084,303327,305349,310678,315715,317713,319828,322974,329922,331450,334138,338275,339091,340158,342727,343825,345811,352389,354360,357271,359004,363560,365373,368001,369697,373966,375444,377618,378752,381244,381987,382616,382663,382287,382016,381890,381343,379793,379296,378889,378539,376388,375845,375522,374614,370716,369296,368408,366354,364600,359528,357097,352999,349965,341182,337268,331273,327326,316741,312308,304845,299455,276999,265960,257145,217897,192839,171875,2822,26028,39148,101814,107907,132866,137177,157859,161984,181640,185354,209186,214396,234767,237795,251081,253510,264807,266910,279006,294302,308794,320948,332523,339521,344610,202630,14945,60262,87217,110752,123744,139123,149370,164061,173989,198589,227785,245975,260158,276934,291484,306528,318777,330765,335032,338765,340931,343386,346924,353497,358437,364530,369200,374756,378559,381768,383013,382608,382032,380133,378828,376843,375492,371593,367722,354894,333583,307835,270116,252975,159603,2542,67246,73496,113485,116275,141215,143511,166181,168331,189191,191648,219324,221871,240590,242153,255685,257092,268826,270075,272910,282321,285873,298760,302237,312031,314592,324197,327007,327996,336553,337335,341579,341945,349348,350472,360721,361807,371524,372354,380057,380615,382717,382754,380892,380756,377983,377820,373965,373583,364013,360790,348334,343165,325656,319168,296737,287432,284024,237310,231122,110024,85816,5757,78175,94801,128464,153489,177798,203886,231303,248461,262425,274974,288615,304264,316639,328806,337798,342273,351415,355508,366414,376385,382307,382335,381315,379641,378391,376205,374474,370140,365688,358480,351720,339463,329417,314736,302252,280565,261782,224879,183073,55315],\"PERCENT_VALUE\":[0.00634,0.00899,0.01924,0.02051,0.02556,0.02643,0.03044,0.03128,0.03517,0.03587,0.0366,0.04141,0.04244,0.04622,0.04677,0.04935,0.0498,0.05201,0.0524,0.05436,0.05477,0.05729,0.05781,0.06018,0.06059,0.06296,0.06523,0.06648,0.06751,0.06973,0.07185,0.07376,0.07481,0.06961,0.06561,0.06063,0.05348,0.04109,0.01041,0.02322,0.02843,0.03328,0.03789,0.04378,0.04422,0.04758,0.04787,0.05046,0.0507,0.05298,0.0532,0.05546,0.05571,0.05863,0.05892,0.0612,0.06141,0.0636,0.06381,0.06562,0.06574,0.06669,0.06678,0.06799,0.06819,0.0704,0.07096,0.07253,0.073,0.07425,0.0745,0.07491,0.07487,0.07486,0.07443,0.0744,0.07386,0.07378,0.07293,0.07281,0.07102,0.07077,0.06781,0.06749,0.06329,0.06285,0.05746,0.05685,0.0485,0.04746,0.02844,0.02519,0.00198,0.00397,0.01623,0.01785,0.02373,0.0247,0.02885,0.02964,0.03367,0.03442,0.03838,0.03939,0.0404,0.04494,0.04559,0.04838,0.04886,0.05114,0.05157,0.05362,0.05398,0.05498,0.05621,0.05675,0.05813,0.05935,0.05974,0.06079,0.06177,0.06216,0.06258,0.06319,0.06455,0.06485,0.06538,0.06619,0.06635,0.06655,0.06706,0.06727,0.06766,0.06895,0.06933,0.0699,0.07024,0.07113,0.07149,0.072,0.07233,0.07317,0.07346,0.07388,0.0741,0.07459,0.07474,0.07486,0.07487,0.0748,0.07474,0.07472,0.07461,0.07431,0.07421,0.07413,0.07406,0.07364,0.07354,0.07347,0.0733,0.07253,0.07225,0.07208,0.07168,0.07134,0.07034,0.06987,0.06907,0.06847,0.06675,0.06599,0.06482,0.06404,0.06197,0.0611,0.05964,0.05859,0.0542,0.05204,0.05031,0.04263,0.03773,0.03363,0.00055,0.00509,0.00766,0.01992,0.02111,0.026,0.02684,0.03089,0.03169,0.03554,0.03627,0.04093,0.04195,0.04593,0.04653,0.04913,0.0496,0.05181,0.05222,0.05459,0.05758,0.06042,0.0628,0.06506,0.06643,0.06742,0.03965,0.00292,0.01179,0.01706,0.02167,0.02421,0.02722,0.02923,0.0321,0.03404,0.03886,0.04457,0.04813,0.0509,0.05418,0.05703,0.05997,0.06237,0.06472,0.06555,0.06628,0.06671,0.06719,0.06788,0.06916,0.07013,0.07132,0.07224,0.07332,0.07407,0.0747,0.07494,0.07486,0.07475,0.07438,0.07412,0.07373,0.07347,0.0727,0.07195,0.06944,0.06527,0.06023,0.05285,0.0495,0.03123,0.0005,0.01316,0.01438,0.0222,0.02275,0.02763,0.02808,0.03251,0.03293,0.03702,0.0375,0.04291,0.04341,0.04707,0.04738,0.05003,0.0503,0.0526,0.05284,0.0534,0.05524,0.05593,0.05845,0.05913,0.06105,0.06155,0.06343,0.06398,0.06417,0.06585,0.066,0.06683,0.0669,0.06835,0.06857,0.07058,0.07079,0.07269,0.07285,0.07436,0.07447,0.07488,0.07489,0.07452,0.0745,0.07395,0.07392,0.07317,0.07309,0.07122,0.07059,0.06815,0.06714,0.06372,0.06245,0.05806,0.05624,0.05557,0.04643,0.04522,0.02153,0.01679,0.00113,0.0153,0.01855,0.02513,0.03003,0.03479,0.03989,0.04526,0.04861,0.05134,0.0538,0.05647,0.05953,0.06195,0.06433,0.06609,0.06697,0.06876,0.06956,0.07169,0.07364,0.0748,0.07481,0.07461,0.07428,0.07403,0.07361,0.07327,0.07242,0.07155,0.07014,0.06882,0.06642,0.06445,0.06158,0.05914,0.05489,0.05122,0.044,0.03582,0.01082]}}\n"; + + @Value("${characterization.endpoint}") + private String endpointCharacterizations; + + /** + * @throws Exception + */ + @Test + public void testDataSources() throws Exception { + final ResponseEntity getEntity = getRestTemplate().getForEntity(this.endpointCharacterizations + "/datasources", + String.class); + assertOk(getEntity); + log.info(getEntity.getBody()); + + Assert.state(getEntity.equals(CharacterizationServiceIT.TEST_DATASOURCES)); + } + + + /** + * @throws Exception + */ + @Test + public void testDashboard() throws Exception { + log.info("Testing " + endpointCharacterizations + " endpoint"); + final ResponseEntity getEntity = getRestTemplate().getForEntity(this.endpointCharacterizations + "/" + NYP_COLUMBIA5_54_DEID + "/dashboard", String.class); + assertOk(getEntity); + log.info(getEntity.getBody()); + Assert.state(getEntity.equals(CharacterizationServiceIT.TEST_DASHBOARD)); + + } + + private void assertOk(final ResponseEntity entity) { + Assert.state(entity.getStatusCode() == HttpStatus.OK); + } + +// @Test +// public void testHeel() { +// log.info("Testing " + this.endpointCharacterizations + "/heel" + " endpoint"); +// final ResponseEntity entity = getRestTemplate().getForEntity(this.endpointCharacterizations + "/NYP-Columbia5.4-deid/" + "heel", String.class); +// } + +} diff --git a/src/test/resources/application-test.properties b/src/test/resources/application-test.properties index 8f91786573..a2ee1b0803 100644 --- a/src/test/resources/application-test.properties +++ b/src/test/resources/application-test.properties @@ -19,4 +19,12 @@ cohortanalysis.endpoint.job=${cohortanalysis.endpoint} jobservice.endpoint=${baseUri}/job jobservice.endpoint.job=${jobservice.endpoint}/{instanceId} jobservice.endpoint.jobexecution=${jobservice.endpoint.job}/execution/{executionId} -jobservice.endpoint.jobexecution.alt=${jobservice.endpoint}/execution/{executionId} \ No newline at end of file +jobservice.endpoint.jobexecution.alt=${jobservice.endpoint}/execution/{executionId} + +#Characterization Service +characterization.endpoint=${baseUri}/characterization + + + + + From f41990ee94cd90903ab863f162fd57754bf4d8f9 Mon Sep 17 00:00:00 2001 From: Mark Velez Date: Fri, 28 Oct 2016 16:47:06 -0400 Subject: [PATCH 2/2] Use same method (getTreemap) for all (non-temporal) treemaps Add generic row mapper, text hack impls made several sql translation-related changes Use same method (getTreemap) for all (non-temporal) treemaps Use AS keyword in all cdm report query aliases Remove text hack and camel case column names in cdm report queries Replace all treemap endpoints with a single generic implementation * Rename all treemap CDM report files to treemap.sql * Enquote aliases in CDM report queries to preserve case * Add GenericRowMapper ctor with ObjectMapper for performance * CDMResultsAnalysisRunner.getTreemap returns ArrayNode Fix condition CDM results queries (by concept) * include conceptId parameter * rename sqlAgeAtFirstDiagnosis to sqlAgeAtFirstOccurrence * modify sqlConditionsByType to check vocabulary_id, not domain_id * cast xCalendarYear to INT in sqlPrevalenceByGenderAgeYear added fixes to row mapping in /person and dashboard implemented /achillesheel, /datadensity started implementation of /death refactored CohortAttributeMapper --> CDMAttributeMapper created new report data objects drop unused/superfluous CDMResultsAnalysisRunner fixed /datadensity Fix queries associated with generic drilldown reports * Data types include conditionera, drug, drugera, measurement, observation, procedure, visit * Queries include AgeAtFirstOccurrence, PrevalenceByGenderAgeYear, ByType, ByMonth * Include parameter @conceptId * Cast xCalendarYear to INT (where applicable) Remove obsoleted code from CDMResultsService (activates observation reports) Standardize names of "by type" query files for cdm reports to sqlByType.sql Applies to condition, drug, measurement, observation, procedure Add cdm_database_schema to CDMResultsAnalysisRunner standard columns (for measurement treemap) Fix typo in sqlVisitDurationByType.sql cleaned up and changes /achillesheel --> /heel Add cdm_database_schema to CDMResultsAnalysisRunner standard columns as per mark-velez/* #e862d53 changed endpoint signature (/heel -->/achillesheel), fixed summary yob and yob in person report fixed null totalRecords element in Data Density report added summary to dashboard report in CDM results service implemented death report removed superfluous code (imports, methods, etc) Reorganize sql files for cdm drilldowns (to reduce text wrangling) (#2) * Remove sql prefix from files names * Camel-case filename * Move drilldown files to folders * Delete treemap files that were reverted back removed unused method - renderDrillDownSql() changed access modifier on several fields and methods removed unused test and related resource made post-rebase reconciliations in prep for PR --- .../ohdsi/webapi/report/CDMAchillesHeel.java | 12 + ...CohortAttribute.java => CDMAttribute.java} | 2 +- .../org/ohdsi/webapi/report/CDMDashboard.java | 129 ++-- .../ohdsi/webapi/report/CDMDataDensity.java | 29 + .../org/ohdsi/webapi/report/CDMDeath.java | 45 ++ .../ohdsi/webapi/report/CDMPersonSummary.java | 40 +- .../report/CDMResultsAnalysisRunner.java | 243 +++++++ ...uteMapper.java => CDMAttributeMapper.java} | 8 +- .../report/mapper/CohortStatsMapper.java | 10 +- .../report/mapper/ConceptCountMapper.java | 6 +- .../mapper/ConceptDecileCountsMapper.java | 2 +- .../report/mapper/ConceptDecileMapper.java | 6 +- .../mapper/ConceptDistributionMapper.java | 6 +- .../report/mapper/ConceptQuartileMapper.java | 3 +- .../mapper/CumulativeObservationMapper.java | 6 +- .../report/mapper/GenericRowMapper.java | 62 ++ .../report/mapper/MonthObservationMapper.java | 6 +- .../mapper/PrevalanceConceptMapper.java | 2 +- .../report/mapper/PrevalanceMapper.java | 6 +- .../report/mapper/SeriesPerPersonMapper.java | 2 +- .../webapi/service/CDMResultsService.java | 610 ++---------------- .../achillesheel/sqlAchillesHeel.sql | 3 + .../condition/sqlAgeAtFirstDiagnosis.sql | 0 .../condition/sqlConditionTreemap.sql | 0 .../condition/sqlConditionsByType.sql | 0 .../sqlPrevalenceByGenderAgeYear.sql | 0 .../condition/sqlPrevalenceByMonth.sql | 0 .../conditionera/sqlAgeAtFirstDiagnosis.sql | 0 .../conditionera/sqlConditionEraTreemap.sql | 0 .../conditionera/sqlLengthOfEra.sql | 0 .../sqlPrevalenceByGenderAgeYear.sql | 0 .../conditionera/sqlPrevalenceByMonth.sql | 0 .../datadensity/conceptsperperson.sql | 76 +++ .../datadensity/recordsperperson.sql | 27 + .../export_v5/datadensity/totalrecords.sql | 24 + .../sql/export_v5/death/sqlAgeAtDeath.sql | 12 + .../sql/export_v5/death/sqlDeathByType.sql | 6 + .../death/sqlPrevalenceByGenderAgeYear.sql | 13 + .../export_v5/death/sqlPrevalenceByMonth.sql | 7 + .../drug/sqlAgeAtFirstExposure.sql | 0 .../drug/sqlDaysSupplyDistribution.sql | 0 .../drug/sqlDrugTreemap.sql | 0 .../drug/sqlDrugsByType.sql | 0 .../drug/sqlPrevalenceByGenderAgeYear.sql | 0 .../drug/sqlPrevalenceByMonth.sql | 0 .../drug/sqlQuantityDistribution.sql | 0 .../drug/sqlRefillsDistribution.sql | 0 .../drugera/sqlAgeAtFirstExposure.sql | 0 .../drugera/sqlDrugEraTreemap.sql | 0 .../drugera/sqlLengthOfEra.sql | 0 .../drugera/sqlPrevalenceByGenderAgeYear.sql | 0 .../drugera/sqlPrevalenceByMonth.sql | 0 .../measurement/sqlAgeAtFirstOccurrence.sql | 0 .../measurement/sqlLowerLimitDistribution.sql | 0 .../measurement/sqlMeasurementTreemap.sql | 0 .../sqlMeasurementValueDistribution.sql | 0 .../measurement/sqlMeasurementsByType.sql | 0 .../sqlPrevalenceByGenderAgeYear.sql | 0 .../measurement/sqlPrevalenceByMonth.sql | 0 .../measurement/sqlRecordsByUnit.sql | 0 .../measurement/sqlUpperLimitDistribution.sql | 0 .../measurement/sqlValuesRelativeToNorm.sql | 0 .../observation/sqlAgeAtFirstOccurrence.sql | 0 .../observation/sqlObservationTreemap.sql | 0 .../observation/sqlObservationsByType.sql | 0 .../sqlPrevalenceByGenderAgeYear.sql | 0 .../observation/sqlPrevalenceByMonth.sql | 0 .../observationperiod/ageatfirst.sql | 10 + .../observationperiod/agebygender.sql | 11 + .../observationperiod/cumulativeduration.sql | 13 + .../observationlength_data.sql | 9 + .../observationlength_stats.sql | 9 + .../observationlengthbyage.sql | 10 + .../observationlengthbygender.sql | 11 + .../observationperiod/observedbymonth.sql | 7 + .../observationperiod/observedbyyear_data.sql | 14 + .../observedbyyear_stats.sql | 5 + .../observationperiod/periodsperperson.sql | 5 + .../sql/export_v5/person/ethnicity.sql | 8 + .../sql/export_v5/person/gender.sql | 9 + .../sql/export_v5/person/population.sql | 19 + .../cdmresults/sql/export_v5/person/race.sql | 8 + .../sql/export_v5/person/yearofbirth_data.sql | 7 + .../export_v5/person/yearofbirth_stats.sql | 5 + .../procedure/sqlAgeAtFirstOccurrence.sql | 0 .../sqlPrevalenceByGenderAgeYear.sql | 0 .../procedure/sqlPrevalenceByMonth.sql | 0 .../procedure/sqlProcedureTreemap.sql | 0 .../procedure/sqlProceduresByType.sql | 0 .../visit/sqlAgeAtFirstOccurrence.sql | 0 .../visit/sqlPrevalenceByGenderAgeYear.sql | 0 .../visit/sqlPrevalenceByMonth.sql | 0 .../visit/sqlVisitDurationByType.sql | 0 .../visit/sqlVisitTreemap.sql | 0 .../cdmresults/sql/getConceptDensity.sql | 30 +- .../cdmresults/sql/getConceptRecordCount.sql | 43 +- .../sql/getConditionOccurrenceTreemap.sql | 210 +++--- .../getDrugEraPrevalenceByGenderAgeYear.sql | 68 +- .../cdmresults/sql/getDrugEraTreemap.sql | 194 +++--- ...etMonthlyConditionOccurrencePrevalence.sql | 34 +- .../report/achillesheel/sqlAchillesHeel.sql | 8 +- .../drilldown/ageAtFirstOccurrence.sql | 19 + .../sql/report/condition/drilldown/byType.sql | 40 ++ .../drilldown/prevalenceByGenderAgeYear.sql | 43 ++ .../condition/drilldown/prevalenceByMonth.sql | 26 + .../sql/report/condition/treemap.sql | 119 ++++ .../drilldown/ageAtFirstOccurrence.sql | 18 + .../conditionera/drilldown/lengthOfEra.sql | 15 + .../drilldown/prevalenceByGenderAgeYear.sql | 42 ++ .../drilldown/prevalenceByMonth.sql | 15 + .../sql/report/conditionera/treemap.sql | 122 ++++ .../report/datadensity/conceptsperperson.sql | 136 ++-- .../report/datadensity/recordsperperson.sql | 89 ++- .../sql/report/datadensity/totalrecords.sql | 83 ++- .../sql/report/death/sqlAgeAtDeath.sql | 25 +- .../sql/report/death/sqlDeathByType.sql | 13 +- .../death/sqlPrevalenceByGenderAgeYear.sql | 33 +- .../sql/report/death/sqlPrevalenceByMonth.sql | 17 +- .../drug/drilldown/ageAtFirstOccurrence.sql | 20 + .../sql/report/drug/drilldown/byType.sql | 14 + .../drug/drilldown/daysSupplyDistribution.sql | 16 + .../drilldown/prevalenceByGenderAgeYear.sql | 41 ++ .../drug/drilldown/prevalenceByMonth.sql | 17 + .../drug/drilldown/quantityDistribution.sql | 16 + .../drug/drilldown/refillsDistribution.sql | 16 + .../cdmresults/sql/report/drug/treemap.sql | 112 ++++ .../drilldown/ageAtFirstOccurrence.sql | 19 + .../report/drugera/drilldown/lengthOfEra.sql | 16 + .../drilldown/prevalenceByGenderAgeYear.sql | 41 ++ .../drugera/drilldown/prevalenceByMonth.sql | 15 + .../cdmresults/sql/report/drugera/treemap.sql | 105 +++ .../drilldown/ageAtFirstOccurrence.sql | 15 + .../report/measurement/drilldown/byType.sql | 11 + .../drilldown/lowerLimitDistribution.sql | 15 + .../measurementValueDistribution.sql | 16 + .../drilldown/prevalenceByGenderAgeYear.sql | 42 ++ .../drilldown/prevalenceByMonth.sql | 17 + .../measurement/drilldown/recordsByUnit.sql | 10 + .../drilldown/upperLimitDistribution.sql | 15 + .../drilldown/valuesRelativeToNorm.sql | 10 + .../sql/report/measurement/treemap.sql | 43 ++ .../drilldown/ageAtFirstOccurrence.sql | 15 + .../report/observation/drilldown/byType.sql | 11 + .../drilldown/prevalenceByGenderAgeYear.sql | 42 ++ .../drilldown/prevalenceByMonth.sql | 17 + .../sql/report/observation/treemap.sql | 43 ++ .../report/observationperiod/ageatfirst.sql | 23 +- .../report/observationperiod/agebygender.sql | 23 +- .../observationperiod/cumulativeduration.sql | 31 +- .../observationlength_data.sql | 15 +- .../observationlength_stats.sql | 15 +- .../observationlengthbyage.sql | 22 +- .../observationlengthbygender.sql | 23 +- .../observationperiod/observedbymonth.sql | 13 +- .../observationperiod/observedbyyear_data.sql | 31 +- .../observedbyyear_stats.sql | 11 +- .../observationperiod/periodsperperson.sql | 13 +- .../sql/report/person/ethnicity.sql | 17 +- .../cdmresults/sql/report/person/gender.sql | 19 +- .../sql/report/person/population.sql | 30 +- .../cdmresults/sql/report/person/race.sql | 17 +- .../sql/report/person/yearofbirth_data.sql | 18 +- .../sql/report/person/yearofbirth_stats.sql | 11 +- .../drilldown/ageAtFirstOccurrence.sql | 19 + .../sql/report/procedure/drilldown/byType.sql | 11 + .../drilldown/prevalenceByGenderAgeYear.sql | 41 ++ .../procedure/drilldown/prevalenceByMonth.sql | 17 + .../sql/report/procedure/treemap.sql | 134 ++++ .../visit/drilldown/ageAtFirstOccurrence.sql | 15 + .../drilldown/prevalenceByGenderAgeYear.sql | 43 ++ .../visit/drilldown/prevalenceByMonth.sql | 17 + .../visit/drilldown/visitDurationByType.sql | 15 + .../cdmresults/sql/report/visit/treemap.sql | 14 + .../test/CharacterizationServiceIT.java | 60 -- .../resources/application-test.properties | 2 - 175 files changed, 3207 insertions(+), 1288 deletions(-) rename src/main/java/org/ohdsi/webapi/report/{CohortAttribute.java => CDMAttribute.java} (95%) create mode 100644 src/main/java/org/ohdsi/webapi/report/CDMDeath.java create mode 100644 src/main/java/org/ohdsi/webapi/report/CDMResultsAnalysisRunner.java rename src/main/java/org/ohdsi/webapi/report/mapper/{CohortAttributeMapper.java => CDMAttributeMapper.java} (54%) create mode 100644 src/main/java/org/ohdsi/webapi/report/mapper/GenericRowMapper.java create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/achillesheel/sqlAchillesHeel.sql rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/condition/sqlAgeAtFirstDiagnosis.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/condition/sqlConditionTreemap.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/condition/sqlConditionsByType.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/condition/sqlPrevalenceByGenderAgeYear.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/condition/sqlPrevalenceByMonth.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/conditionera/sqlAgeAtFirstDiagnosis.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/conditionera/sqlConditionEraTreemap.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/conditionera/sqlLengthOfEra.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/conditionera/sqlPrevalenceByGenderAgeYear.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/conditionera/sqlPrevalenceByMonth.sql (100%) create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/datadensity/conceptsperperson.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/datadensity/recordsperperson.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/datadensity/totalrecords.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/death/sqlAgeAtDeath.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/death/sqlDeathByType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/death/sqlPrevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/death/sqlPrevalenceByMonth.sql rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drug/sqlAgeAtFirstExposure.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drug/sqlDaysSupplyDistribution.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drug/sqlDrugTreemap.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drug/sqlDrugsByType.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drug/sqlPrevalenceByGenderAgeYear.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drug/sqlPrevalenceByMonth.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drug/sqlQuantityDistribution.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drug/sqlRefillsDistribution.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drugera/sqlAgeAtFirstExposure.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drugera/sqlDrugEraTreemap.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drugera/sqlLengthOfEra.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drugera/sqlPrevalenceByGenderAgeYear.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/drugera/sqlPrevalenceByMonth.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/measurement/sqlAgeAtFirstOccurrence.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/measurement/sqlLowerLimitDistribution.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/measurement/sqlMeasurementTreemap.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/measurement/sqlMeasurementValueDistribution.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/measurement/sqlMeasurementsByType.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/measurement/sqlPrevalenceByGenderAgeYear.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/measurement/sqlPrevalenceByMonth.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/measurement/sqlRecordsByUnit.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/measurement/sqlUpperLimitDistribution.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/measurement/sqlValuesRelativeToNorm.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/observation/sqlAgeAtFirstOccurrence.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/observation/sqlObservationTreemap.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/observation/sqlObservationsByType.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/observation/sqlPrevalenceByGenderAgeYear.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/observation/sqlPrevalenceByMonth.sql (100%) create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/ageatfirst.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/agebygender.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/cumulativeduration.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlength_data.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlength_stats.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlengthbyage.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlengthbygender.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observedbymonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observedbyyear_data.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observedbyyear_stats.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/periodsperperson.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/person/ethnicity.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/person/gender.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/person/population.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/person/race.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/person/yearofbirth_data.sql create mode 100644 src/main/resources/resources/cdmresults/sql/export_v5/person/yearofbirth_stats.sql rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/procedure/sqlAgeAtFirstOccurrence.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/procedure/sqlPrevalenceByGenderAgeYear.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/procedure/sqlPrevalenceByMonth.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/procedure/sqlProcedureTreemap.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/procedure/sqlProceduresByType.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/visit/sqlAgeAtFirstOccurrence.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/visit/sqlPrevalenceByGenderAgeYear.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/visit/sqlPrevalenceByMonth.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/visit/sqlVisitDurationByType.sql (100%) rename src/main/resources/resources/cdmresults/sql/{report => export_v5}/visit/sqlVisitTreemap.sql (100%) create mode 100644 src/main/resources/resources/cdmresults/sql/report/condition/drilldown/ageAtFirstOccurrence.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/condition/drilldown/byType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/condition/drilldown/prevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/condition/drilldown/prevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/condition/treemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/ageAtFirstOccurrence.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/lengthOfEra.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/prevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/prevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/conditionera/treemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/drilldown/ageAtFirstOccurrence.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/drilldown/byType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/drilldown/daysSupplyDistribution.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/drilldown/prevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/drilldown/prevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/drilldown/quantityDistribution.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/drilldown/refillsDistribution.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drug/treemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/ageAtFirstOccurrence.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/lengthOfEra.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/prevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/prevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/drugera/treemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/ageAtFirstOccurrence.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/byType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/lowerLimitDistribution.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/measurementValueDistribution.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/prevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/prevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/recordsByUnit.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/upperLimitDistribution.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/valuesRelativeToNorm.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/measurement/treemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observation/drilldown/ageAtFirstOccurrence.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observation/drilldown/byType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observation/drilldown/prevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observation/drilldown/prevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/observation/treemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/ageAtFirstOccurrence.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/byType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/prevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/prevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/procedure/treemap.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/visit/drilldown/ageAtFirstOccurrence.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/visit/drilldown/prevalenceByGenderAgeYear.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/visit/drilldown/prevalenceByMonth.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/visit/drilldown/visitDurationByType.sql create mode 100644 src/main/resources/resources/cdmresults/sql/report/visit/treemap.sql delete mode 100644 src/test/java/org/ohdsi/webapi/test/CharacterizationServiceIT.java diff --git a/src/main/java/org/ohdsi/webapi/report/CDMAchillesHeel.java b/src/main/java/org/ohdsi/webapi/report/CDMAchillesHeel.java index a87adc8a99..fdc1a3f40e 100644 --- a/src/main/java/org/ohdsi/webapi/report/CDMAchillesHeel.java +++ b/src/main/java/org/ohdsi/webapi/report/CDMAchillesHeel.java @@ -1,7 +1,19 @@ package org.ohdsi.webapi.report; +import java.util.List; + /** * Created by taa7016 on 10/4/2016. */ public class CDMAchillesHeel { + + private List messages; + + public void setMessages(List messages) { + this.messages = messages; + } + + public List getMessages(){ + return messages; + } } diff --git a/src/main/java/org/ohdsi/webapi/report/CohortAttribute.java b/src/main/java/org/ohdsi/webapi/report/CDMAttribute.java similarity index 95% rename from src/main/java/org/ohdsi/webapi/report/CohortAttribute.java rename to src/main/java/org/ohdsi/webapi/report/CDMAttribute.java index ee2951045a..7c587e1bd8 100644 --- a/src/main/java/org/ohdsi/webapi/report/CohortAttribute.java +++ b/src/main/java/org/ohdsi/webapi/report/CDMAttribute.java @@ -1,6 +1,6 @@ package org.ohdsi.webapi.report; -public class CohortAttribute { +public class CDMAttribute { private String attributeName; private String attributeValue; diff --git a/src/main/java/org/ohdsi/webapi/report/CDMDashboard.java b/src/main/java/org/ohdsi/webapi/report/CDMDashboard.java index 3c41892aad..d997a2d8a4 100644 --- a/src/main/java/org/ohdsi/webapi/report/CDMDashboard.java +++ b/src/main/java/org/ohdsi/webapi/report/CDMDashboard.java @@ -4,60 +4,77 @@ public class CDMDashboard { - private List gender; - private List ageAtFirstObservation; - private List cumulativeObservation; - private List observedByMonth; - /** - * @return the gender - */ - public List getGender() { - return gender; - } - /** - * @param gender the gender to set - */ - public void setGender(List gender) { - this.gender = gender; - } - /** - * @return the ageAtFirstObservation - */ - public List getAgeAtFirstObservation() { - return ageAtFirstObservation; - } - /** - * @param ageAtFirstObservation the ageAtFirstObservation to set - */ - public void setAgeAtFirstObservation( - List ageAtFirstObservation) { - this.ageAtFirstObservation = ageAtFirstObservation; - } - /** - * @return the cumulativeObservation - */ - public List getCumulativeObservation() { - return cumulativeObservation; - } - /** - * @param cumulativeObservation the cumulativeObservation to set - */ - public void setCumulativeObservation( - List cumulativeObservation) { - this.cumulativeObservation = cumulativeObservation; - } - /** - * @return the observedByMonth - */ - public List getObservedByMonth() { - return observedByMonth; - } - /** - * @param observedByMonth the observedByMonth to set - */ - public void setObservedByMonth(List observedByMonth) { - this.observedByMonth = observedByMonth; - } - - + private List summary; + private List gender; + private List ageAtFirstObservation; + private List cumulativeObservation; + private List observedByMonth; + + public List getSummary() { + return summary; + } + + public void setSummary(List summary) { + this.summary = summary; + } + + /** + * @return the gender + */ + public List getGender() { + return gender; + } + + /** + * @param gender the gender to set + */ + public void setGender(List gender) { + this.gender = gender; + } + + /** + * @return the ageAtFirstObservation + */ + public List getAgeAtFirstObservation() { + return ageAtFirstObservation; + } + + /** + * @param ageAtFirstObservation the ageAtFirstObservation to set + */ + public void setAgeAtFirstObservation( + List ageAtFirstObservation) { + this.ageAtFirstObservation = ageAtFirstObservation; + } + + /** + * @return the cumulativeObservation + */ + public List getCumulativeObservation() { + return cumulativeObservation; + } + + /** + * @param cumulativeObservation the cumulativeObservation to set + */ + public void setCumulativeObservation( + List cumulativeObservation) { + this.cumulativeObservation = cumulativeObservation; + } + + /** + * @return the observedByMonth + */ + public List getObservedByMonth() { + return observedByMonth; + } + + /** + * @param observedByMonth the observedByMonth to set + */ + public void setObservedByMonth(List observedByMonth) { + this.observedByMonth = observedByMonth; + } + + } diff --git a/src/main/java/org/ohdsi/webapi/report/CDMDataDensity.java b/src/main/java/org/ohdsi/webapi/report/CDMDataDensity.java index 8e98ccbfc8..fd810faa0b 100644 --- a/src/main/java/org/ohdsi/webapi/report/CDMDataDensity.java +++ b/src/main/java/org/ohdsi/webapi/report/CDMDataDensity.java @@ -1,7 +1,36 @@ package org.ohdsi.webapi.report; +import java.util.List; + /** * Created by taa7016 on 10/4/2016. */ public class CDMDataDensity { + private List conceptsPerPerson; + private List recordsPerPerson; + private List totalRecords; + + public List getTotalRecords() { + return totalRecords; + } + + public void setTotalRecords(List totalRecords) { + this.totalRecords = totalRecords; + } + + public List getRecordsPerPerson() { + return recordsPerPerson; + } + + public void setRecordsPerPerson(List recordsPerPerson) { + this.recordsPerPerson = recordsPerPerson; + } + + public List getConceptsPerPerson() { + return conceptsPerPerson; + } + + public void setConceptsPerPerson(List conceptsPerPerson) { + this.conceptsPerPerson = conceptsPerPerson; + } } diff --git a/src/main/java/org/ohdsi/webapi/report/CDMDeath.java b/src/main/java/org/ohdsi/webapi/report/CDMDeath.java new file mode 100644 index 0000000000..8669b1ec67 --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CDMDeath.java @@ -0,0 +1,45 @@ +package org.ohdsi.webapi.report; + +import java.util.List; + +/** + * Created by taa7016 on 11/29/2016. + */ +public class CDMDeath { + private List ageAtDeath; + private List deathByType; + private List prevalenceByGenderAgeYear; + private List prevalenceByMonth; + + public void setDeathByType(List deathByType) { + this.deathByType = deathByType; + } + + public List getDeathByType() { + return deathByType; + } + + public List getPrevalenceByGenderAgeYear() { + return prevalenceByGenderAgeYear; + } + + public void setPrevalenceByGenderAgeYear(List prevalenceByGenderAgeYear) { + this.prevalenceByGenderAgeYear = prevalenceByGenderAgeYear; + } + + public void setAgeAtDeath(List ageAtDeath) { + this.ageAtDeath = ageAtDeath; + } + + public List getAgeAtDeath() { + return ageAtDeath; + } + + public List getPrevalenceByMonth() { + return prevalenceByMonth; + } + + public void setPrevalenceByMonth(List prevalenceByMonth) { + this.prevalenceByMonth = prevalenceByMonth; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/CDMPersonSummary.java b/src/main/java/org/ohdsi/webapi/report/CDMPersonSummary.java index bfe395ddd5..7debcd109a 100644 --- a/src/main/java/org/ohdsi/webapi/report/CDMPersonSummary.java +++ b/src/main/java/org/ohdsi/webapi/report/CDMPersonSummary.java @@ -7,68 +7,84 @@ */ public class CDMPersonSummary { - private List yearOfBirth; - private List yearOfBirthStats; - + private List summary; private List gender; private List race; private List ethnicity; + private List yearOfBirth; + private List yearOfBirthStats; /** - * @return the YearOfBirth + * @return the summary */ - public List getYearOfBirth() { - return yearOfBirth; + public List getSummary() { + return summary; } + /** - * @param YearOfBirth the YearOfBirth to set + * @param summary the summary to set */ - public void setYearOfBirth( - List yearOfBirth) { + public void setSummary(List summary) { + this.summary = summary; + } + + public List getYearOfBirth() { + return yearOfBirth; + } + + public void setYearOfBirth(List yearOfBirth) { this.yearOfBirth = yearOfBirth; } + /** - * @return the Summary + * @return the yearOfBirthStats */ - public List getSummary() { + public List getYearOfBirthStats() { return yearOfBirthStats; } + /** * @param yearOfBirthStats the yearOfBirthStats to set */ - public void setSummary(List yearOfBirthStats) { + public void setYearOfBirthStats(List yearOfBirthStats) { this.yearOfBirthStats = yearOfBirthStats; } + /** * @return the gender */ public List getGender() { return gender; } + /** * @param gender the gender to set */ public void setGender(List gender) { this.gender = gender; } + /** * @return the race */ public List getRace() { return race; } + /** * @param race the race to set */ public void setRace(List race) { this.race = race; } + /** * @return the ethnicity */ public List getEthnicity() { return ethnicity; } + /** * @param ethnicity the ethnicity to set */ diff --git a/src/main/java/org/ohdsi/webapi/report/CDMResultsAnalysisRunner.java b/src/main/java/org/ohdsi/webapi/report/CDMResultsAnalysisRunner.java new file mode 100644 index 0000000000..b1c5e9f83b --- /dev/null +++ b/src/main/java/org/ohdsi/webapi/report/CDMResultsAnalysisRunner.java @@ -0,0 +1,243 @@ +package org.ohdsi.webapi.report; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.ohdsi.sql.SqlRender; +import org.ohdsi.sql.SqlTranslate; +import org.ohdsi.webapi.helper.ResourceHelper; +import org.ohdsi.webapi.report.mapper.*; +import org.ohdsi.webapi.source.Source; +import org.ohdsi.webapi.source.SourceDaimon; +import org.springframework.core.io.Resource; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.core.io.support.ResourcePatternResolver; +import org.springframework.jdbc.core.JdbcTemplate; + +import java.util.List; + +public class CDMResultsAnalysisRunner { + + private static final String BASE_SQL_PATH = "/resources/cdmresults/sql"; + + private static final Log log = LogFactory.getLog(CDMResultsAnalysisRunner.class); + + private static final String[] STANDARD_COLUMNS = new String[]{"results_database_schema", "vocab_database_schema", "cdm_database_schema"}; + + private static final String[] DRILLDOWN_COLUMNS = new String[]{"results_database_schema", "vocab_database_schema", "conceptId"}; + + private ObjectMapper mapper; + + private String sourceDialect; + + public CDMResultsAnalysisRunner(String sourceDialect) { + + this.sourceDialect = sourceDialect; + mapper = new ObjectMapper(); + } + + public CDMDashboard getDashboard(JdbcTemplate jdbcTemplate, + Source source) { + + CDMDashboard dashboard = new CDMDashboard(); + + String summarySql = this.renderTranslateSql(BASE_SQL_PATH + "/report/person/population.sql", source); + if (summarySql != null) { + dashboard.setSummary(jdbcTemplate.query(summarySql, new CDMAttributeMapper())); + } + + String ageAtFirstObsSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/observationperiod/ageatfirst.sql", source); + if (ageAtFirstObsSql != null) { + dashboard.setAgeAtFirstObservation(jdbcTemplate.query(ageAtFirstObsSql, new ConceptDistributionMapper())); + } + + String genderSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/person/gender.sql", source); + if (genderSql != null) { + dashboard.setGender(jdbcTemplate.query(genderSql, new ConceptCountMapper())); + } + + String cumulObsSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/observationperiod/cumulativeduration.sql", source); + if (cumulObsSql != null) { + dashboard.setCumulativeObservation(jdbcTemplate.query(cumulObsSql, new CumulativeObservationMapper())); + } + + String obsByMonthSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/observationperiod/observedbymonth.sql", source); + if (obsByMonthSql != null) { + dashboard.setObservedByMonth(jdbcTemplate.query(obsByMonthSql, new MonthObservationMapper())); + } + + return dashboard; + + } + + /** + * Queries for CDM person results for the given source + * + * @param jdbcTemplate JDBCTemplate + * @return CDMPersonSummary + */ + public CDMPersonSummary getPersonResults(JdbcTemplate jdbcTemplate, + final Source source) { + + CDMPersonSummary person = new CDMPersonSummary(); + + String summarySql = this.renderTranslateSql(BASE_SQL_PATH + "/report/person/population.sql", source); + if (summarySql != null) { + person.setSummary(jdbcTemplate.query(summarySql, new CDMAttributeMapper())); + } + + String genderSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/person/gender.sql", source); + if (genderSql != null) { + person.setGender(jdbcTemplate.query(genderSql, new ConceptCountMapper())); + } + + String raceSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/person/race.sql", source); + if (raceSql != null) { + person.setRace(jdbcTemplate.query(raceSql, new ConceptCountMapper())); + } + + String ethnicitySql = this.renderTranslateSql(BASE_SQL_PATH + "/report/person/ethnicity.sql", source); + if (ethnicitySql != null) { + person.setEthnicity(jdbcTemplate.query(ethnicitySql, new ConceptCountMapper())); + } + + String yearOfBirthSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/person/yearofbirth_data.sql", source); + if (yearOfBirthSql != null) { + person.setYearOfBirth(jdbcTemplate.query(yearOfBirthSql, new ConceptDistributionMapper())); + } + + String yearOfBirthStatsSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/person/yearofbirth_stats.sql", source); + if (yearOfBirthStatsSql != null) { + person.setYearOfBirthStats(jdbcTemplate.query(yearOfBirthStatsSql, new CohortStatsMapper())); + } + + return person; + } + + public CDMAchillesHeel getHeelResults(JdbcTemplate jdbcTemplate, Source source) { + CDMAchillesHeel heel = new CDMAchillesHeel(); + String achillesSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/achillesheel/sqlAchillesHeel.sql", source); + if (achillesSql != null) { + heel.setMessages(jdbcTemplate.query(achillesSql, new CDMAttributeMapper())); + } + return heel; + } + + public CDMDataDensity getDataDensityResults(JdbcTemplate jdbcTemplate, Source source) { + CDMDataDensity cdmDataDensity = new CDMDataDensity(); + String conceptsPerPersonSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/datadensity/conceptsperperson.sql", source); + if (conceptsPerPersonSql != null) { + cdmDataDensity.setConceptsPerPerson(jdbcTemplate.query(conceptsPerPersonSql, new ConceptQuartileMapper())); + } + String recordsPerPersonSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/datadensity/recordsperperson.sql", source); + if (recordsPerPersonSql != null) { + cdmDataDensity.setRecordsPerPerson(jdbcTemplate.query(recordsPerPersonSql, new SeriesPerPersonMapper())); + } + String totalRecordsSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/datadensity/totalrecords.sql", source); + if (totalRecordsSql != null) { + cdmDataDensity.setTotalRecords(jdbcTemplate.query(totalRecordsSql, new SeriesPerPersonMapper())); + } + return cdmDataDensity; + } + + public CDMDeath getDeathResults(JdbcTemplate jdbcTemplate, Source source) { + CDMDeath cdmDeath = new CDMDeath(); + String prevalenceByGenderAgeYearSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/death/sqlPrevalenceByGenderAgeYear.sql", source); + if (prevalenceByGenderAgeYearSql != null) { + cdmDeath.setPrevalenceByGenderAgeYear(jdbcTemplate.query(prevalenceByGenderAgeYearSql, new ConceptDecileMapper())); + } + String prevalenceByMonthSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/death/sqlPrevalenceByMonth.sql", source); + if (prevalenceByMonthSql != null) { + cdmDeath.setPrevalenceByMonth(jdbcTemplate.query(prevalenceByMonthSql, new PrevalanceMapper())); + } + String deathByTypeSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/death/sqlDeathByType.sql", source); + if (deathByTypeSql != null) { + cdmDeath.setDeathByType(jdbcTemplate.query(deathByTypeSql, new ConceptCountMapper())); + } + String ageAtDeathSql = this.renderTranslateSql(BASE_SQL_PATH + "/report/death/sqlAgeAtDeath.sql", source); + if (ageAtDeathSql != null) { + cdmDeath.setAgeAtDeath(jdbcTemplate.query(ageAtDeathSql, new ConceptQuartileMapper())); + } + return cdmDeath; + } + + private String renderTranslateSql(String sqlPath, Source source) { + return renderTranslateSql(sqlPath, null, source); + } + + + public ArrayNode getTreemap(JdbcTemplate jdbcTemplate, + String domain, + Source source) { + ObjectMapper mapper = new ObjectMapper(); + ArrayNode arrayNode = mapper.createArrayNode(); + + String sqlPath = BASE_SQL_PATH + "/report/" + domain.toLowerCase() + "/treemap.sql"; + String sql = this.renderTranslateSql(sqlPath, source); + if (sql != null) { + List list = jdbcTemplate.query(sql, new GenericRowMapper(mapper)); + arrayNode.addAll(list); + } + return arrayNode; + } + + public JsonNode getDrilldown(JdbcTemplate jdbcTemplate, + final String domain, + final int conceptId, + Source source) { + ObjectMapper mapper = new ObjectMapper(); + ObjectNode objectNode = mapper.createObjectNode(); + + ClassLoader cl = this.getClass().getClassLoader(); + ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(cl); + String pattern = BASE_SQL_PATH + "/report/" + domain.toLowerCase() + "/drilldown/*.sql"; + try { + Resource[] resources = resolver.getResources(pattern); + for (Resource resource : resources) { + String fullSqlPath = resource.getURL().getPath(); + int startIndex = fullSqlPath.indexOf(BASE_SQL_PATH); + String sqlPath = fullSqlPath.substring(startIndex); + String sql = this.renderTranslateSql(sqlPath, conceptId, source); + if (sql != null) { + List l = jdbcTemplate.query(sql, new GenericRowMapper(mapper)); + String analysisName = resource.getFilename().replace(".sql", ""); + objectNode.putArray(analysisName).addAll(l); + } + } + } catch (Exception e) { + log.error(e); + } + return objectNode; + } + + private String renderTranslateSql(String sqlPath, Integer conceptId, Source source) { + String sql = null; + + String resultsTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); + String vocabularyTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Vocabulary); + String cdmTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.CDM); + + try { + String[] cols; + String[] colValues; + if (conceptId != null) { + cols = DRILLDOWN_COLUMNS; + colValues = new String[]{resultsTableQualifier, vocabularyTableQualifier, String.valueOf(conceptId)}; + } else { + cols = STANDARD_COLUMNS; + colValues = new String[]{resultsTableQualifier, vocabularyTableQualifier, cdmTableQualifier}; + } + + sql = ResourceHelper.GetResourceAsString(sqlPath); + sql = SqlRender.renderSql(sql, cols, colValues); + sql = SqlTranslate.translateSql(sql, sourceDialect, source.getSourceDialect()); + } catch (Exception e) { + log.error(String.format("Unable to translate sql for %s", sql), e); + } + + return sql; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/CohortAttributeMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/CDMAttributeMapper.java similarity index 54% rename from src/main/java/org/ohdsi/webapi/report/mapper/CohortAttributeMapper.java rename to src/main/java/org/ohdsi/webapi/report/mapper/CDMAttributeMapper.java index e19fe1f2d5..4231e2d308 100644 --- a/src/main/java/org/ohdsi/webapi/report/mapper/CohortAttributeMapper.java +++ b/src/main/java/org/ohdsi/webapi/report/mapper/CDMAttributeMapper.java @@ -1,16 +1,16 @@ package org.ohdsi.webapi.report.mapper; -import org.ohdsi.webapi.cohortresults.CohortAttribute; +import org.ohdsi.webapi.report.CDMAttribute; import org.springframework.jdbc.core.RowMapper; import java.sql.ResultSet; import java.sql.SQLException; -public class CohortAttributeMapper implements RowMapper { +public class CDMAttributeMapper implements RowMapper { @Override - public CohortAttribute mapRow(ResultSet rs, int rowNum) throws SQLException { - CohortAttribute attribute = new CohortAttribute(); + public CDMAttribute mapRow(ResultSet rs, int rowNum) throws SQLException { + CDMAttribute attribute = new CDMAttribute(); attribute.setAttributeName(rs.getString("ATTRIBUTE_NAME")); attribute.setAttributeValue(rs.getString("ATTRIBUTE_VALUE")); return attribute; diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/CohortStatsMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/CohortStatsMapper.java index a46702660e..540776b02e 100644 --- a/src/main/java/org/ohdsi/webapi/report/mapper/CohortStatsMapper.java +++ b/src/main/java/org/ohdsi/webapi/report/mapper/CohortStatsMapper.java @@ -1,6 +1,6 @@ package org.ohdsi.webapi.report.mapper; -import org.ohdsi.webapi.cohortresults.CohortStatsRecord; +import org.ohdsi.webapi.report.CohortStatsRecord; import org.springframework.jdbc.core.RowMapper; import java.sql.ResultSet; @@ -12,10 +12,10 @@ public class CohortStatsMapper implements RowMapper { public CohortStatsRecord mapRow(ResultSet rs, int rowNum) throws SQLException { CohortStatsRecord stats = new CohortStatsRecord(); - stats.setIntervalSize(rs.getInt("INTERVAL_SIZE")); - stats.setMaxValue(rs.getInt("MAX_VALUE")); - stats.setMinValue(rs.getInt("MIN_VALUE")); - return stats; + stats.setIntervalSize(rs.getInt("INTERVALSIZE")); + stats.setMaxValue(rs.getInt("MAXVALUE")); + stats.setMinValue(rs.getInt("MINVALUE")); + return stats; } } diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptCountMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptCountMapper.java index e632dcf5b3..ca13669ee8 100644 --- a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptCountMapper.java +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptCountMapper.java @@ -11,9 +11,9 @@ public class ConceptCountMapper implements RowMapper { @Override public ConceptCountRecord mapRow(ResultSet rs, int rowNum) throws SQLException { ConceptCountRecord record = new ConceptCountRecord(); - record.setConceptId(rs.getLong("CONCEPT_ID")); - record.setConceptName(rs.getString("CONCEPT_NAME")); - record.setCountValue(rs.getLong("COUNT_VALUE")); + record.setConceptId(rs.getLong("CONCEPTID")); + record.setConceptName(rs.getString("CONCEPTNAME")); + record.setCountValue(rs.getLong("COUNTVALUE")); return record; } diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileCountsMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileCountsMapper.java index b78e75dd76..4424ce5180 100644 --- a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileCountsMapper.java +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileCountsMapper.java @@ -1,6 +1,6 @@ package org.ohdsi.webapi.report.mapper; -import org.ohdsi.webapi.cohortresults.ConceptDecileRecord; +import org.ohdsi.webapi.report.ConceptDecileRecord; import org.springframework.jdbc.core.RowMapper; import java.sql.ResultSet; diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileMapper.java index 192f27a8df..de179077d0 100644 --- a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileMapper.java +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDecileMapper.java @@ -1,6 +1,6 @@ package org.ohdsi.webapi.report.mapper; -import org.ohdsi.webapi.cohortresults.ConceptDecileRecord; +import org.ohdsi.webapi.report.ConceptDecileRecord; import org.springframework.jdbc.core.RowMapper; import java.sql.ResultSet; @@ -12,8 +12,8 @@ public class ConceptDecileMapper implements RowMapper { public ConceptDecileRecord mapRow(ResultSet rs, int rowNum) throws SQLException { ConceptDecileRecord record = new ConceptDecileRecord(); record.setTrellisName(rs.getString("TRELLIS_NAME")); - record.setConceptId(rs.getLong("CONCEPT_ID")); - record.setSeriesName(rs.getString("SERIES_NAME")); +// record.setConceptId(rs.getLong("CONCEPT_ID")); + record.setSeriesName(rs.getString("SERIES_NAME")); record.setyPrevalence1000Pp(rs.getDouble("Y_PREVALENCE_1000PP")); record.setxCalendarYear(rs.getInt("X_CALENDAR_YEAR")); return record; diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDistributionMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDistributionMapper.java index 7397534b14..dd3860e7b4 100644 --- a/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDistributionMapper.java +++ b/src/main/java/org/ohdsi/webapi/report/mapper/ConceptDistributionMapper.java @@ -12,9 +12,9 @@ public class ConceptDistributionMapper implements RowMapper { public ConceptQuartileRecord mapRow(ResultSet rs, int rowNum) throws SQLException { ConceptQuartileRecord record = new ConceptQuartileRecord(); record.setCategory(rs.getString("CATEGORY")); - record.setConceptId(rs.getLong("CONCEPT_ID")); record.setMaxValue(rs.getInt("MAX_VALUE")); record.setP75Value(rs.getInt("P75_VALUE")); record.setP10Value(rs.getInt("P10_VALUE")); diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/CumulativeObservationMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/CumulativeObservationMapper.java index ba304ac628..c738878f18 100644 --- a/src/main/java/org/ohdsi/webapi/report/mapper/CumulativeObservationMapper.java +++ b/src/main/java/org/ohdsi/webapi/report/mapper/CumulativeObservationMapper.java @@ -11,9 +11,9 @@ public class CumulativeObservationMapper implements RowMapper { + private final ObjectMapper mapper; + + public GenericRowMapper(ObjectMapper mapper) { + this.mapper = mapper; + } + + @Override + public JsonNode mapRow(ResultSet rs, int rowNum) throws SQLException { + ObjectNode objectNode = mapper.createObjectNode(); + ResultSetMetaData rsmd = rs.getMetaData(); + int columnCount = rsmd.getColumnCount(); + for (int index = 1; index <= columnCount; index++) { + String column = JdbcUtils.lookupColumnName(rsmd, index); + Object value = rs.getObject(column); + if (value == null) { + objectNode.putNull(column); + } else if (value instanceof Integer) { + objectNode.put(column, (Integer) value); + } else if (value instanceof String) { + objectNode.put(column, (String) value); + } else if (value instanceof Boolean) { + objectNode.put(column, (Boolean) value); + } else if (value instanceof Date) { + objectNode.put(column, ((Date) value).getTime()); + } else if (value instanceof Long) { + objectNode.put(column, (Long) value); + } else if (value instanceof Double) { + objectNode.put(column, (Double) value); + } else if (value instanceof Float) { + objectNode.put(column, (Float) value); + } else if (value instanceof BigDecimal) { + objectNode.put(column, (BigDecimal) value); + } else if (value instanceof Byte) { + objectNode.put(column, (Byte) value); + } else if (value instanceof byte[]) { + objectNode.put(column, (byte[]) value); + } else { + throw new IllegalArgumentException("Unmappable object type: " + value.getClass()); + } + } + return objectNode; + } +} diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/MonthObservationMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/MonthObservationMapper.java index ee44695591..e516778233 100644 --- a/src/main/java/org/ohdsi/webapi/report/mapper/MonthObservationMapper.java +++ b/src/main/java/org/ohdsi/webapi/report/mapper/MonthObservationMapper.java @@ -11,9 +11,9 @@ public class MonthObservationMapper implements RowMapper @Override public MonthObservationRecord mapRow(ResultSet rs, int rowNum) throws SQLException { MonthObservationRecord record = new MonthObservationRecord(); - record.setMonthYear(rs.getInt("MONTH_YEAR")); - record.setPercentValue(rs.getDouble("PERCENT_VALUE")); - record.setCountValue(rs.getLong("COUNT_VALUE")); + record.setMonthYear(rs.getInt("MONTHYEAR")); + record.setPercentValue(rs.getDouble("PERCENTVALUE")); + record.setCountValue(rs.getLong("COUNTVALUE")); return record; } diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceConceptMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceConceptMapper.java index cca4d2e000..0d9bdda78c 100644 --- a/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceConceptMapper.java +++ b/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceConceptMapper.java @@ -1,6 +1,6 @@ package org.ohdsi.webapi.report.mapper; -import org.ohdsi.webapi.cohortresults.PrevalenceRecord; +import org.ohdsi.webapi.report.PrevalenceRecord; import org.springframework.jdbc.core.RowMapper; import java.sql.ResultSet; diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceMapper.java index cc186447c5..25a7c01603 100644 --- a/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceMapper.java +++ b/src/main/java/org/ohdsi/webapi/report/mapper/PrevalanceMapper.java @@ -1,6 +1,6 @@ package org.ohdsi.webapi.report.mapper; -import org.ohdsi.webapi.cohortresults.PrevalenceRecord; +import org.ohdsi.webapi.report.PrevalenceRecord; import org.springframework.jdbc.core.RowMapper; import java.sql.ResultSet; @@ -14,8 +14,8 @@ public PrevalenceRecord mapRow(ResultSet rs, int rowNum) PrevalenceRecord record = new PrevalenceRecord(); record.setyPrevalence1000Pp(rs.getDouble("Y_PREVALENCE_1000PP")); record.setxCalendarMonth(rs.getInt("X_CALENDAR_MONTH")); - record.setNumPersons(rs.getInt("NUM_PERSONS")); - return record; +// record.setNumPersons(rs.getInt("NUM_PERSONS")); + return record; } } diff --git a/src/main/java/org/ohdsi/webapi/report/mapper/SeriesPerPersonMapper.java b/src/main/java/org/ohdsi/webapi/report/mapper/SeriesPerPersonMapper.java index 75643b0c47..c820c3c72b 100644 --- a/src/main/java/org/ohdsi/webapi/report/mapper/SeriesPerPersonMapper.java +++ b/src/main/java/org/ohdsi/webapi/report/mapper/SeriesPerPersonMapper.java @@ -1,6 +1,6 @@ package org.ohdsi.webapi.report.mapper; -import org.ohdsi.webapi.cohortresults.SeriesPerPerson; +import org.ohdsi.webapi.report.SeriesPerPerson; import org.springframework.jdbc.core.RowMapper; import java.sql.ResultSet; diff --git a/src/main/java/org/ohdsi/webapi/service/CDMResultsService.java b/src/main/java/org/ohdsi/webapi/service/CDMResultsService.java index de51d666f0..d34c956844 100644 --- a/src/main/java/org/ohdsi/webapi/service/CDMResultsService.java +++ b/src/main/java/org/ohdsi/webapi/service/CDMResultsService.java @@ -8,19 +8,16 @@ import javax.ws.rs.*; import javax.ws.rs.core.MediaType; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; import org.apache.commons.lang3.StringUtils; import org.ohdsi.sql.SqlRender; import org.ohdsi.sql.SqlTranslate; import org.ohdsi.webapi.report.*; -import org.ohdsi.webapi.report.mapper.*; -//import org.ohdsi.webapi.cohortresults.VisualizationData; import org.ohdsi.webapi.helper.ResourceHelper; import org.ohdsi.webapi.source.Source; import org.ohdsi.webapi.source.SourceDaimon; -import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.ResultSetExtractor; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Component; @@ -31,40 +28,11 @@ @Component public class CDMResultsService extends AbstractDaoService { - private ObjectMapper mapper = new ObjectMapper(); private CDMResultsAnalysisRunner queryRunner = null; @PostConstruct public void init() { - queryRunner = new CDMResultsAnalysisRunner(this.getSourceDialect()/*, this.visualizationDataRepository*/); - } - - @Path("{conceptId}/monthlyConditionOccurrencePrevalence") - @GET - @Produces(MediaType.APPLICATION_JSON) - public MonthlyPrevalence getMonthlyConditionOccurrencePrevalence(@PathParam("sourceKey") String sourceKey, @PathParam("conceptId") String conceptId) { - try { - Source source = getSourceRepository().findBySourceKey(sourceKey); - String tableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); - - String sql_statement = ResourceHelper.GetResourceAsString("/resources/cdmresults/sql/getMonthlyConditionOccurrencePrevalence.sql"); - sql_statement = SqlRender.renderSql(sql_statement, new String[]{"OHDSI_schema", "conceptId"}, new String[]{tableQualifier, conceptId}); - sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect()); - - return getSourceJdbcTemplate(source).query(sql_statement, new ResultSetExtractor() { - @Override - public MonthlyPrevalence extractData(ResultSet rs) throws SQLException, DataAccessException { - MonthlyPrevalence result = new MonthlyPrevalence(); - while (rs.next()) { - result.monthKey.add(rs.getString(1)); - result.prevalence.add(rs.getFloat(2)); - } - return result; - } - }); - } catch (Exception exception) { - throw new RuntimeException("Error retrieving monthly condition occurrence prevalence statistics." + exception.getMessage()); - } + queryRunner = new CDMResultsAnalysisRunner(this.getSourceDialect()); } private final RowMapper> rowMapper = new RowMapper>() { @@ -101,116 +69,34 @@ public List> getConceptRecordCount(@PathParam("sourceK } /** - * Queries for CDM dashboard for the given sourceKey + * Queries for dashboard report for the sourceKey * * @return CDMDashboard */ @GET @Path("dashboard") @Produces(MediaType.APPLICATION_JSON) - public CDMDashboard getDashboard(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { + public CDMDashboard getDashboard(@PathParam("sourceKey") final String sourceKey) { - final String key = CDMResultsAnalysisRunner.DASHBOARD; Source source = getSourceRepository().findBySourceKey(sourceKey); -// AchillesVisualizationData data = /*refresh ?*/ null /* : this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(id, source.getSourceId(), key)*/; - - CDMDashboard dashboard = null; - - if (refresh /*|| data == null*/) { - dashboard = queryRunner.getDashboard(getSourceJdbcTemplate(source), /*id,*/ source, /*demographicsOnly,*/ true); - } else { - try { -// dashboard = mapper.readValue(data.getData(), CDMDashboard.class); - } catch (Exception e) { - log.error(e); - } - } - + CDMDashboard dashboard = queryRunner.getDashboard(getSourceJdbcTemplate(source), source); return dashboard; - } /** - * Queries for person report results for the given sourceKey + * Queries for person report for the sourceKey * * @return CDMPersonSummary */ @GET @Path("person") @Produces(MediaType.APPLICATION_JSON) - public CDMPersonSummary getPersonReport(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { - CDMPersonSummary person = null; - final String key = CDMResultsAnalysisRunner.PERSON; + public CDMPersonSummary getPerson(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { Source source = getSourceRepository().findBySourceKey(sourceKey); -// AchillesVisualizationData data = /* refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; - - if (refresh /*|| data == null*/) { - person = this.queryRunner.getPersonResults(this.getSourceJdbcTemplate(source), source, true); - } else { - try { -// person = mapper.readValue(data.getData(), CDMPersonSummary.class); - } catch (Exception e) { - log.error(e); - } - } - + CDMPersonSummary person = this.queryRunner.getPersonResults(this.getSourceJdbcTemplate(source), source); return person; } - /** - * Queries for drug report results for the given sourceKey - * - * @return CDMDrugSummary - */ - @GET - @Path("drug") - @Produces(MediaType.APPLICATION_JSON) - public CDMDrugSummary getDrugReport(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { - CDMDrugSummary drugSummary = null; - final String key = CDMResultsAnalysisRunner.DRUG; - Source source = getSourceRepository().findBySourceKey(sourceKey); -// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; - - if (refresh /*|| data == null*/) { - drugSummary = this.queryRunner.getDrugResults(this.getSourceJdbcTemplate(source), source, true); - } else { - try { -// drugSummary = mapper.readValue(data.getData(), CDMDrugSummary.class); - } catch (Exception e) { - log.error(e); - } - } - - return drugSummary; - } - - /** - * Queries for person report results for the given sourceKey - * - * @return CDMProcedureSummary - */ - @GET - @Path("procedure") - @Produces(MediaType.APPLICATION_JSON) - public CDMProcedureSummary getProcedureReport(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { - CDMProcedureSummary procedureSummary = null; - final String key = CDMResultsAnalysisRunner.PROCEDURE; - Source source = getSourceRepository().findBySourceKey(sourceKey); -// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; - - if (refresh /*|| data == null*/) { - procedureSummary = this.queryRunner.getProcedureResults(this.getSourceJdbcTemplate(source), source, true); - } else { - try { -// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); - } catch (Exception e) { - log.error(e); - } - } - - return procedureSummary; - } - /** * Queries for achilles heel report for the given sourceKey * @@ -220,77 +106,11 @@ public CDMProcedureSummary getProcedureReport(@PathParam("sourceKey") final Stri @Path("achillesheel") @Produces(MediaType.APPLICATION_JSON) public CDMAchillesHeel getAchillesHeelReport(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { - CDMAchillesHeel cdmAchillesHeel = null; - final String key = CDMResultsAnalysisRunner.HEEL; Source source = getSourceRepository().findBySourceKey(sourceKey); -// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; - - if (refresh /*|| data == null*/) { - cdmAchillesHeel = this.queryRunner.getHeelResults(this.getSourceJdbcTemplate(source), source, true); - } else { - try { -// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); - } catch (Exception e) { - log.error(e); - } - } - + CDMAchillesHeel cdmAchillesHeel = this.queryRunner.getHeelResults(this.getSourceJdbcTemplate(source), source); return cdmAchillesHeel; } - /** - * Queries for observation period report for the given sourceKey - * - * @return CDMObservationPeriod - */ - @GET - @Path("observationperiod") - @Produces(MediaType.APPLICATION_JSON) - public CDMObservationPeriod getObservationPeriods(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { - CDMObservationPeriod cdmObservationPeriod = null; - final String key = CDMResultsAnalysisRunner.OBSERVATIONPERIOD; - Source source = getSourceRepository().findBySourceKey(sourceKey); -// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; - - if (refresh /*|| data == null*/) { - cdmObservationPeriod = this.queryRunner.getObservationPeriodResults(this.getSourceJdbcTemplate(source), source, true); - } else { - try { -// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); - } catch (Exception e) { - log.error(e); - } - } - - return cdmObservationPeriod; - } - - /** - * Queries for observations report for the given sourceKey - * - * @return CDMObservation - */ - @GET - @Path("observation") - @Produces(MediaType.APPLICATION_JSON) - public List getObservations(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { - List cdmObservationPeriods = null; - final String key = CDMResultsAnalysisRunner.OBSERVATION; - Source source = getSourceRepository().findBySourceKey(sourceKey); -// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; - - if (refresh /*|| data == null*/) { - cdmObservationPeriods = this.queryRunner.getObservationResults(this.getSourceJdbcTemplate(source), source, true); - } else { - try { -// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); - } catch (Exception e) { - log.error(e); - } - } - - return cdmObservationPeriods; - } /** * Queries for data density report for the given sourceKey @@ -301,111 +121,26 @@ public List getObservations(@PathParam("sourceKey") final String @Path("datadensity") @Produces(MediaType.APPLICATION_JSON) public CDMDataDensity getDataDensity(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { - CDMDataDensity cdmDataDensity = null; - final String key = CDMResultsAnalysisRunner.DATADENSITY; + CDMDataDensity cdmDataDensity; Source source = getSourceRepository().findBySourceKey(sourceKey); -// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; - - if (refresh /*|| data == null*/) { - cdmDataDensity = this.queryRunner.getDataDensityResults(this.getSourceJdbcTemplate(source), source, true); - } else { - try { -// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); - } catch (Exception e) { - log.error(e); - } - } - + cdmDataDensity = this.queryRunner.getDataDensityResults(this.getSourceJdbcTemplate(source), source); return cdmDataDensity; } /** - * Queries for condition report for the given sourceKey + * Queries for death report for the given sourceKey + * Queries for treemap results * - * @return CDMConditionTree - */ - @GET - @Path("condition_treemap") - @Produces(MediaType.APPLICATION_JSON) - public List getConditionTreeMap(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { - List cdmConditions = null; - final String key = CDMResultsAnalysisRunner.CONDITION; - Source source = getSourceRepository().findBySourceKey(sourceKey); -// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; - - if (refresh /*|| data == null*/) { - cdmConditions = this.queryRunner.getCondition(this.getSourceJdbcTemplate(source), source, true); - } else { - try { -// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); - } catch (Exception e) { - log.error(e); - } - } - - return cdmConditions; - } - - /** - * Queries for condition era report for the given sourceKey - * - * @return CDMConditionEra + * @return CDMDataDensity */ @GET - @Path("conditionera_treemap") + @Path("death") @Produces(MediaType.APPLICATION_JSON) - public List getConditionEraTreeMap(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { - List cdmConditionEras = null; - final String key = CDMResultsAnalysisRunner.CONDITIONERA; + public CDMDeath getDeath(@PathParam("sourceKey") final String sourceKey, @DefaultValue("false") @QueryParam("refresh") boolean refresh) { + CDMDeath cdmDeath; Source source = getSourceRepository().findBySourceKey(sourceKey); -// AchillesVisualizationData data = /*refresh ?*/ null /*: this.visualizationDataRepository.findByCohortDefinitionIdAndSourceIdAndVisualizationKey(source.getSourceId(), key)*/; - - if (refresh /*|| data == null*/) { - cdmConditionEras = this.queryRunner.getConditionEras(this.getSourceJdbcTemplate(source), source, true); - } else { - try { -// procedureSummary = mapper.readValue(data.getData(), CDMProcedureSummary.class); - } catch (Exception e) { - log.error(e); - } - } - - return cdmConditionEras; - } - - - @Path("drugeratreemap") - @POST - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - public List getDrugEraTreemap(@PathParam("sourceKey") String sourceKey, String[] identifiers) { - Source source = getSourceRepository().findBySourceKey(sourceKey); - String tableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); - String vocabularyTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Vocabulary); - - for (int i = 0; i < identifiers.length; i++) { - identifiers[i] = "'" + identifiers[i] + "'"; - } - - String identifierList = StringUtils.join(identifiers, ","); - String sql_statement = ResourceHelper.GetResourceAsString("/resources/cdmresults/sql/getDrugEraTreemap.sql"); - sql_statement = SqlRender.renderSql(sql_statement, new String[]{"ohdsi_database_schema", "vocabulary_database_schema", "conceptList"}, new String[]{tableQualifier, vocabularyTableQualifier, identifierList}); - sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect()); - - - List> rows = getSourceJdbcTemplate(source).queryForList(sql_statement); - List listOfResults = new ArrayList(); - for (Map rs : rows) { - DrugPrevalence d = new DrugPrevalence(); - d.conceptId = Long.valueOf(String.valueOf(rs.get("concept_id"))); - d.conceptPath = String.valueOf(rs.get("concept_path")); - d.lengthOfEra = Float.valueOf(String.valueOf(rs.get("length_of_era"))); - d.numPersons = Long.valueOf(String.valueOf(rs.get("num_persons"))); - d.percentPersons = Float.valueOf(String.valueOf(rs.get("percent_persons"))); - listOfResults.add(d); - } - - return listOfResults; + cdmDeath = this.queryRunner.getDeathResults(this.getSourceJdbcTemplate(source), source); + return cdmDeath; } @Path("{conceptId}/drugeraprevalence") @@ -472,284 +207,35 @@ public List getConditionOccurrenceTreemap(@PathP return listOfResults; } - class CDMResultsAnalysisRunner { - - public static final String DASHBOARD = "dashboard"; - public static final String PERSON = "person"; - public static final String BASE_SQL_PATH = "/resources/cdmresults/sql"; - public static final String DRUG = "drug"; - public static final String CONDITION = "condition"; - public static final String CONDITIONERA = "conditionera"; - public static final String OBSERVATIONPERIOD = "observationperiod"; - public static final String HEEL = "heel"; - public static final String PROCEDURE = "procedure"; - public static final String DATADENSITY = "datadensity"; - public static final String OBSERVATION = "observation"; - - public /*static*/ final String[] STANDARD_COLUMNS = new String[]{"cdm_database_schema", - "results_database_schema"/*, "cohortDefinitionId", - "minCovariatePersonCount", "minIntervalPersonCount"*/}; - - public /*static*/ final String[] DRILLDOWN_COLUMNS = new String[]{"cdm_database_schema", - "results_database_schema", /*"cohortDefinitionId", - "minCovariatePersonCount", "minIntervalPersonCount",*/ "conceptId"}; - - private ObjectMapper mapper; - private String sourceDialect; - -// private AchillesVisualizationDataRepository visualizationDataRepository; - - public CDMResultsAnalysisRunner(String sourceDialect) { - - this.sourceDialect = sourceDialect; -// this.visualizationDataRepository = visualizationDataRepository; - mapper = new ObjectMapper(); - } - - public CDMDashboard getDashboard(JdbcTemplate jdbcTemplate, - /*int id,*/ Source source, - /*boolean demographicsOnly,*/ - boolean save) { - - final String key = DASHBOARD; - CDMDashboard dashboard = new CDMDashboard(); - boolean empty = true; - - String ageAtFirstObsSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/observationperiod/ageatfirst.sql", null, source); - if (ageAtFirstObsSql != null) { - dashboard.setAgeAtFirstObservation(jdbcTemplate.query(ageAtFirstObsSql, new ConceptDistributionMapper())); - } - - String genderSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/gender.sql", null, source); - if (genderSql != null) { - dashboard.setGender(jdbcTemplate.query(genderSql, new ConceptCountMapper())); - } - -// if (!demographicsOnly) { - String cumulObsSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/observationperiod/cumulativeduration.sql", null, source); - if (cumulObsSql != null) { - dashboard.setCumulativeObservation(jdbcTemplate.query(cumulObsSql, new CumulativeObservationMapper())); - } - - String obsByMonthSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/observationperiod/observedbymonth.sql", null, source); - if (obsByMonthSql != null) { - dashboard.setObservedByMonth(jdbcTemplate.query(obsByMonthSql, new MonthObservationMapper())); - } -// } - -// if (CollectionUtils.isNotEmpty(dashboard.getAgeAtFirstObservation()) -// || CollectionUtils.isNotEmpty(dashboard.getCumulativeObservation()) -// || CollectionUtils.isNotEmpty(dashboard.getGender()) -// || CollectionUtils.isNotEmpty(dashboard.getObservedByMonth())) { -// empty = false; -// } -// -// if (!empty && save) { -// this.saveEntity(id, source.getSourceId(), key, dashboard); -// } - - return dashboard; - - } - - /** - * Queries for CDM person results for the given source - * - * @param jdbcTemplate JDBCTemplate - * @return CDMPersonSummary - */ - public CDMPersonSummary getPersonResults(JdbcTemplate jdbcTemplate, - final Source source, - boolean save) { - - final String key = PERSON; - CDMPersonSummary person = new CDMPersonSummary(); - boolean empty = true; - Integer id = null; - - String personSummaryData = this.renderTranslateCohortSql(BASE_SQL_PATH + "/report/person/population.sql", null, source); - if (personSummaryData != null) { - person.setYearOfBirth(jdbcTemplate.query(personSummaryData, new ConceptDistributionMapper())); - } - -// String yobStatSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/yearofbirth_stats.sql", id, minCovariatePersonCountParam, minIntervalPersonCountParam, source); -// if (yobStatSql != null) { -// person.setYearOfBirthStats(jdbcTemplate.query(yobStatSql, new CohortStatsMapper())); -// } - - String genderSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/gender.sql", id, /*minCovariatePersonCountParam, minIntervalPersonCountParam,*/ source); - if (genderSql != null) { - person.setGender(jdbcTemplate.query(genderSql, new ConceptCountMapper())); - } - - String raceSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/race.sql", id, /*minCovariatePersonCountParam, minIntervalPersonCountParam,*/ source); - if (raceSql != null) { - person.setRace(jdbcTemplate.query(raceSql, new ConceptCountMapper())); - } - - String ethnicitySql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/ethnicity.sql", id, /*minCovariatePersonCountParam, minIntervalPersonCountParam,*/ source); - if (ethnicitySql != null) { - person.setEthnicity(jdbcTemplate.query(ethnicitySql, new ConceptCountMapper())); - } - -// if (CollectionUtils.isNotEmpty(person.getEthnicity()) -// || CollectionUtils.isNotEmpty(person.getGender()) -// || CollectionUtils.isNotEmpty(person.getRace()) -// || CollectionUtils.isNotEmpty(person.getYearOfBirth()) -// || CollectionUtils.isNotEmpty(person.getYearOfBirthStats())) { -// empty = false; -// } -// -// if (!empty && save) { -// this.saveEntity(id, source.getSourceId(), key, person); -// } - - return person; - } - - /** - * Passes in common params for cdm results, and performs SQL - * translate/render - */ - public String renderTranslateCohortSql(String sqlPath, Integer id, Integer conceptId, - Source source) { - String sql = null; - - String resultsTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Results); - String vocabularyTableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Vocabulary); - - try { - String[] cols; - String[] colValues; - if (conceptId != null) { - cols = DRILLDOWN_COLUMNS; - colValues = new String[]{vocabularyTableQualifier, - resultsTableQualifier, /*String.valueOf(id), - minCovariatePersonCountParam == null ? MIN_COVARIATE_PERSON_COUNT - : minCovariatePersonCountParam, - minIntervalPersonCountParam == null ? MIN_INTERVAL_PERSON_COUNT - : minIntervalPersonCountParam,*/ - String.valueOf(conceptId)}; - } else { - cols = STANDARD_COLUMNS; - colValues = new String[]{vocabularyTableQualifier, - resultsTableQualifier, /*String.valueOf(id), - minCovariatePersonCountParam == null ? MIN_COVARIATE_PERSON_COUNT - : minCovariatePersonCountParam, - minIntervalPersonCountParam == null ? MIN_INTERVAL_PERSON_COUNT - : minIntervalPersonCountParam*/}; - } - - sql = ResourceHelper.GetResourceAsString(sqlPath); - sql = SqlRender.renderSql(sql, cols, colValues); - sql = SqlTranslate.translateSql(sql, sourceDialect, source.getSourceDialect()); - } catch (Exception e) { - log.error(String.format("Unable to translate sql for %s", sql), e); - } - - return sql; - } - - /** - * Passes in common params for cdm results, and performs SQL - * translate/render - */ - public String renderTranslateCohortSql(String sqlPath, Integer id, - Source source) { - return renderTranslateCohortSql(sqlPath, id, null, source); - } - - public CDMDrugSummary getDrugResults(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { - final String key = PERSON; - CDMDrugSummary cdmDrugSummary = new CDMDrugSummary(); - boolean empty = true; - - String personSummaryData = this.renderTranslateCohortSql(BASE_SQL_PATH + "report/person/population.sql", null, source); - - -// if (CollectionUtils.isNotEmpty(person.getEthnicity()) -// || CollectionUtils.isNotEmpty(person.getGender()) -// || CollectionUtils.isNotEmpty(person.getRace()) -// || CollectionUtils.isNotEmpty(person.getYearOfBirth()) -// || CollectionUtils.isNotEmpty(person.getYearOfBirthStats())) { -// empty = false; -// } - -// if (!empty && save) { -// this.saveEntity(id, source.getSourceId(), key, person); -// } - - return cdmDrugSummary; - } - - public CDMProcedureSummary getProcedureResults(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { - final String key = PERSON; - CDMProcedureSummary cdmProcedureSummary = new CDMProcedureSummary(); - boolean empty = true; - - String personSummaryData = this.renderTranslateCohortSql(BASE_SQL_PATH + "report/person/population.sql", null, source); -// if (personSummaryData != null) { -// person.setYearOfBirth(jdbcTemplate.query(yobSql, new ConceptDistributionMapper())); -// } - -// String yobStatSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/yearofbirth_stats.sql", id, minCovariatePersonCountParam, minIntervalPersonCountParam, source); -// if (yobStatSql != null) { -// person.setYearOfBirthStats(jdbcTemplate.query(yobStatSql, new CohortStatsMapper())); -// } -// -// String genderSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/gender.sql", id, minCovariatePersonCountParam, minIntervalPersonCountParam, source); -// if (genderSql != null) { -// person.setGender(jdbcTemplate.query(genderSql, new ConceptCountMapper())); -// } -// -// String raceSql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/race.sql", id, minCovariatePersonCountParam, minIntervalPersonCountParam, source); -// if (raceSql != null) { -// person.setRace(jdbcTemplate.query(raceSql, new ConceptCountMapper())); -// } -// -// String ethnicitySql = this.renderTranslateCohortSql(BASE_SQL_PATH + "/person/ethnicity.sql", id, minCovariatePersonCountParam, minIntervalPersonCountParam, source); -// if (ethnicitySql != null) { -// person.setEthnicity(jdbcTemplate.query(ethnicitySql, new ConceptCountMapper())); -// } -// -// if (CollectionUtils.isNotEmpty(person.getEthnicity()) -// || CollectionUtils.isNotEmpty(person.getGender()) -// || CollectionUtils.isNotEmpty(person.getRace()) -// || CollectionUtils.isNotEmpty(person.getYearOfBirth()) -// || CollectionUtils.isNotEmpty(person.getYearOfBirthStats())) { -// empty = false; -// } -// -// if (!empty && save) { -// this.saveEntity(id, source.getSourceId(), key, person); -// } - - return cdmProcedureSummary; - } - - public CDMAchillesHeel getHeelResults(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { - return new CDMAchillesHeel(); - } - - public CDMObservationPeriod getObservationPeriodResults(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { - return new CDMObservationPeriod(); - } - - public CDMDataDensity getDataDensityResults(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { - return new CDMDataDensity(); - } - - public List getCondition(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { - return new ArrayList(); - } - - public List getConditionEras(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { - return new ArrayList(); - } + /** + * Queries for measurement treemap results + * + * @return List + */ + @GET + @Path("/{domain}/") + @Produces(MediaType.APPLICATION_JSON) + public ArrayNode getTreemap( + @PathParam("domain") final String domain, + @PathParam("sourceKey") final String sourceKey) { + Source source = getSourceRepository().findBySourceKey(sourceKey); + return queryRunner.getTreemap(this.getSourceJdbcTemplate(source), domain, source); + } - public List getObservationResults(JdbcTemplate sourceJdbcTemplate, Source source, boolean b) { - return new ArrayList(); - } + /** + * Queries for drilldown results + * + * @return List + */ + @GET + @Path("/{domain}/{conceptId}") + @Produces(MediaType.APPLICATION_JSON) + public JsonNode getDrilldown(@PathParam("domain") final String domain, + @PathParam("conceptId") final int conceptId, + @PathParam("sourceKey") final String sourceKey) { + Source source = getSourceRepository().findBySourceKey(sourceKey); + JdbcTemplate jdbcTemplate = this.getSourceJdbcTemplate(source); + return queryRunner.getDrilldown(jdbcTemplate, domain, conceptId, source); } } diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/achillesheel/sqlAchillesHeel.sql b/src/main/resources/resources/cdmresults/sql/export_v5/achillesheel/sqlAchillesHeel.sql new file mode 100644 index 0000000000..5ce0602ea8 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/achillesheel/sqlAchillesHeel.sql @@ -0,0 +1,3 @@ +select analysis_id as AttributeName, ACHILLES_HEEL_warning as AttributeValue +from @results_database_schema.ACHILLES_HEEL_results +order by case when left(ACHILLES_HEEL_warning,5) = 'Error' then 1 else 2 end, analysis_id \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/sqlAgeAtFirstDiagnosis.sql b/src/main/resources/resources/cdmresults/sql/export_v5/condition/sqlAgeAtFirstDiagnosis.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/condition/sqlAgeAtFirstDiagnosis.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/condition/sqlAgeAtFirstDiagnosis.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/sqlConditionTreemap.sql b/src/main/resources/resources/cdmresults/sql/export_v5/condition/sqlConditionTreemap.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/condition/sqlConditionTreemap.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/condition/sqlConditionTreemap.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/sqlConditionsByType.sql b/src/main/resources/resources/cdmresults/sql/export_v5/condition/sqlConditionsByType.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/condition/sqlConditionsByType.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/condition/sqlConditionsByType.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/export_v5/condition/sqlPrevalenceByGenderAgeYear.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/condition/sqlPrevalenceByGenderAgeYear.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/condition/sqlPrevalenceByGenderAgeYear.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/export_v5/condition/sqlPrevalenceByMonth.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/condition/sqlPrevalenceByMonth.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/condition/sqlPrevalenceByMonth.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlAgeAtFirstDiagnosis.sql b/src/main/resources/resources/cdmresults/sql/export_v5/conditionera/sqlAgeAtFirstDiagnosis.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/conditionera/sqlAgeAtFirstDiagnosis.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/conditionera/sqlAgeAtFirstDiagnosis.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlConditionEraTreemap.sql b/src/main/resources/resources/cdmresults/sql/export_v5/conditionera/sqlConditionEraTreemap.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/conditionera/sqlConditionEraTreemap.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/conditionera/sqlConditionEraTreemap.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlLengthOfEra.sql b/src/main/resources/resources/cdmresults/sql/export_v5/conditionera/sqlLengthOfEra.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/conditionera/sqlLengthOfEra.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/conditionera/sqlLengthOfEra.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/export_v5/conditionera/sqlPrevalenceByGenderAgeYear.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/conditionera/sqlPrevalenceByGenderAgeYear.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/conditionera/sqlPrevalenceByGenderAgeYear.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/export_v5/conditionera/sqlPrevalenceByMonth.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/conditionera/sqlPrevalenceByMonth.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/conditionera/sqlPrevalenceByMonth.sql diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/datadensity/conceptsperperson.sql b/src/main/resources/resources/cdmresults/sql/export_v5/datadensity/conceptsperperson.sql new file mode 100644 index 0000000000..b39918d883 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/datadensity/conceptsperperson.sql @@ -0,0 +1,76 @@ +select 'Condition occurrence' as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 403 + +union + +select 'Procedure occurrence' as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 603 + +union + +select 'Drug exposure' as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 703 + +union + +select 'Observation' as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 803 + +union + +select 'Drug era' as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 903 + +union + +select 'Condition era' as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 1003 + diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/datadensity/recordsperperson.sql b/src/main/resources/resources/cdmresults/sql/export_v5/datadensity/recordsperperson.sql new file mode 100644 index 0000000000..7e6a1787de --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/datadensity/recordsperperson.sql @@ -0,0 +1,27 @@ +select t1.table_name as SERIES_NAME, + t1.stratum_1 as X_CALENDAR_MONTH, + round(1.0*t1.count_value/denom.count_value,5) as Y_RECORD_COUNT +from +( + select 'Visit occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 220 + union all + select 'Condition occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 420 + union all + select 'Death' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 502 + union all + select 'Procedure occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 620 + union all + select 'Drug exposure' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 720 + union all + select 'Observation' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 820 + union all + select 'Drug era' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 920 + union all + select 'Condition era' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 1020 + union all + select 'Observation period' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 111 +) t1 +inner join +(select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom +on t1.stratum_1 = denom.stratum_1 +ORDER BY SERIES_NAME, CAST(t1.stratum_1 as INT) diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/datadensity/totalrecords.sql b/src/main/resources/resources/cdmresults/sql/export_v5/datadensity/totalrecords.sql new file mode 100644 index 0000000000..78d7508f17 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/datadensity/totalrecords.sql @@ -0,0 +1,24 @@ +select table_name as SERIES_NAME, + stratum_1 as X_CALENDAR_MONTH, + count_value as Y_RECORD_COUNT +from +( + select 'Visit occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 220 + union all + select 'Condition occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 420 + union all + select 'Death' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 502 + union all + select 'Procedure occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 620 + union all + select 'Drug exposure' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 720 + union all + select 'Observation' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 820 + union all + select 'Drug era' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 920 + union all + select 'Condition era' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 1020 + union all + select 'Observation period' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 111 +) t1 +ORDER BY SERIES_NAME, CAST(stratum_1 as INT) \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/death/sqlAgeAtDeath.sql b/src/main/resources/resources/cdmresults/sql/export_v5/death/sqlAgeAtDeath.sql new file mode 100644 index 0000000000..9c61cbf843 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/death/sqlAgeAtDeath.sql @@ -0,0 +1,12 @@ +select c2.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as P10_value, + ard1.p25_value as P25_value, + ard1.median_value as median_value, + ard1.p75_value as P75_value, + ard1.p90_value as P90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 + inner join + @vocab_database_schema.concept c2 on ard1.stratum_1 = CAST(c2.concept_id as VARCHAR) +where ard1.analysis_id = 506 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/death/sqlDeathByType.sql b/src/main/resources/resources/cdmresults/sql/export_v5/death/sqlDeathByType.sql new file mode 100644 index 0000000000..570560aaa3 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/death/sqlDeathByType.sql @@ -0,0 +1,6 @@ +select c2.concept_id as concept_id, + c2.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join @vocab_database_schema.concept c2 on ar1.stratum_1 = CAST(c2.concept_id as VARCHAR) +where ar1.analysis_id = 505 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/death/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/export_v5/death/sqlPrevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..7127c7937f --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/death/sqlPrevalenceByGenderAgeYear.sql @@ -0,0 +1,13 @@ +select cast(cast(num.stratum_3 as int)*10 as varchar) + '-' + cast((cast(num.stratum_3 as int)+1)*10-1 as varchar) as trellis_name, --age decile + c2.concept_name as series_name, --gender + num.stratum_1 as x_calendar_year, -- calendar year, note, there could be blanks + ROUND(1000*(1.0*num.count_value/denom.count_value),5) as y_prevalence_1000pp --prevalence, per 1000 persons +from + (select * from @results_database_schema.ACHILLES_results where analysis_id = 504) num + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 116) denom on num.stratum_1 = denom.stratum_1 --calendar year + and num.stratum_2 = denom.stratum_2 --gender + and num.stratum_3 = denom.stratum_3 --age decile + inner join @vocab_database_schema.concept c2 on num.stratum_2 = CAST(c2.concept_id as VARCHAR) +where c2.concept_id in (8507, 8532) + diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/death/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/export_v5/death/sqlPrevalenceByMonth.sql new file mode 100644 index 0000000000..39235d7ab1 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/death/sqlPrevalenceByMonth.sql @@ -0,0 +1,7 @@ +select num.stratum_1 as x_calendar_month, -- calendar year, note, there could be blanks + 1000*(1.0*num.count_value/denom.count_value) as y_prevalence_1000pp --prevalence, per 1000 persons +from + (select * from @results_database_schema.ACHILLES_results where analysis_id = 502) num + inner join + (select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom on num.stratum_1 = denom.stratum_1 --calendar year + diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlAgeAtFirstExposure.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlAgeAtFirstExposure.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drug/sqlAgeAtFirstExposure.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlAgeAtFirstExposure.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlDaysSupplyDistribution.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlDaysSupplyDistribution.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drug/sqlDaysSupplyDistribution.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlDaysSupplyDistribution.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlDrugTreemap.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlDrugTreemap.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drug/sqlDrugTreemap.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlDrugTreemap.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlDrugsByType.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlDrugsByType.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drug/sqlDrugsByType.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlDrugsByType.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlPrevalenceByGenderAgeYear.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drug/sqlPrevalenceByGenderAgeYear.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlPrevalenceByGenderAgeYear.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlPrevalenceByMonth.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drug/sqlPrevalenceByMonth.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlPrevalenceByMonth.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlQuantityDistribution.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlQuantityDistribution.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drug/sqlQuantityDistribution.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlQuantityDistribution.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/sqlRefillsDistribution.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlRefillsDistribution.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drug/sqlRefillsDistribution.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drug/sqlRefillsDistribution.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/sqlAgeAtFirstExposure.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drugera/sqlAgeAtFirstExposure.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drugera/sqlAgeAtFirstExposure.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drugera/sqlAgeAtFirstExposure.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/sqlDrugEraTreemap.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drugera/sqlDrugEraTreemap.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drugera/sqlDrugEraTreemap.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drugera/sqlDrugEraTreemap.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/sqlLengthOfEra.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drugera/sqlLengthOfEra.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drugera/sqlLengthOfEra.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drugera/sqlLengthOfEra.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drugera/sqlPrevalenceByGenderAgeYear.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drugera/sqlPrevalenceByGenderAgeYear.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drugera/sqlPrevalenceByGenderAgeYear.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/export_v5/drugera/sqlPrevalenceByMonth.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/drugera/sqlPrevalenceByMonth.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/drugera/sqlPrevalenceByMonth.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlAgeAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlAgeAtFirstOccurrence.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/measurement/sqlAgeAtFirstOccurrence.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlAgeAtFirstOccurrence.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlLowerLimitDistribution.sql b/src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlLowerLimitDistribution.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/measurement/sqlLowerLimitDistribution.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlLowerLimitDistribution.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementTreemap.sql b/src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlMeasurementTreemap.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementTreemap.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlMeasurementTreemap.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementValueDistribution.sql b/src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlMeasurementValueDistribution.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementValueDistribution.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlMeasurementValueDistribution.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementsByType.sql b/src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlMeasurementsByType.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/measurement/sqlMeasurementsByType.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlMeasurementsByType.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlPrevalenceByGenderAgeYear.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/measurement/sqlPrevalenceByGenderAgeYear.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlPrevalenceByGenderAgeYear.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlPrevalenceByMonth.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/measurement/sqlPrevalenceByMonth.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlPrevalenceByMonth.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlRecordsByUnit.sql b/src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlRecordsByUnit.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/measurement/sqlRecordsByUnit.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlRecordsByUnit.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlUpperLimitDistribution.sql b/src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlUpperLimitDistribution.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/measurement/sqlUpperLimitDistribution.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlUpperLimitDistribution.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/sqlValuesRelativeToNorm.sql b/src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlValuesRelativeToNorm.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/measurement/sqlValuesRelativeToNorm.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/measurement/sqlValuesRelativeToNorm.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/sqlAgeAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observation/sqlAgeAtFirstOccurrence.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/observation/sqlAgeAtFirstOccurrence.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/observation/sqlAgeAtFirstOccurrence.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/sqlObservationTreemap.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observation/sqlObservationTreemap.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/observation/sqlObservationTreemap.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/observation/sqlObservationTreemap.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/sqlObservationsByType.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observation/sqlObservationsByType.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/observation/sqlObservationsByType.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/observation/sqlObservationsByType.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observation/sqlPrevalenceByGenderAgeYear.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/observation/sqlPrevalenceByGenderAgeYear.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/observation/sqlPrevalenceByGenderAgeYear.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observation/sqlPrevalenceByMonth.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/observation/sqlPrevalenceByMonth.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/observation/sqlPrevalenceByMonth.sql diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/ageatfirst.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/ageatfirst.sql new file mode 100644 index 0000000000..00956a3c6e --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/ageatfirst.sql @@ -0,0 +1,10 @@ +select cast(ar1.stratum_1 as int) as interval_index, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from +( + select * from @results_database_schema.ACHILLES_results where analysis_id = 101 +) ar1, +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/agebygender.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/agebygender.sql new file mode 100644 index 0000000000..66992b463d --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/agebygender.sql @@ -0,0 +1,11 @@ +select c1.concept_name as Category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) +where ard1.analysis_id = 104 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/cumulativeduration.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/cumulativeduration.sql new file mode 100644 index 0000000000..7542e49c47 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/cumulativeduration.sql @@ -0,0 +1,13 @@ +select 'Length of observation' as series_name, + cast(ar1.stratum_1 as int)*30 as x_length_of_observation, + round(1.0*sum(ar2.count_value) / denom.count_value,5) as y_percent_persons +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 108) ar1 +inner join +( + select * from @results_database_schema.ACHILLES_results where analysis_id = 108 +) ar2 on ar1.analysis_id = ar2.analysis_id and cast(ar1.stratum_1 as int) <= cast(ar2.stratum_1 as int), +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom +group by cast(ar1.stratum_1 as int)*30, denom.count_value +order by cast(ar1.stratum_1 as int)*30 asc diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlength_data.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlength_data.sql new file mode 100644 index 0000000000..ca38aba3a3 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlength_data.sql @@ -0,0 +1,9 @@ +select cast(ar1.stratum_1 as int) as interval_index, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from @results_database_schema.ACHILLES_analysis aa1 +inner join @results_database_schema.ACHILLES_results ar1 on aa1.analysis_id = ar1.analysis_id, +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom +where aa1.analysis_id = 108 diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlength_stats.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlength_stats.sql new file mode 100644 index 0000000000..52f311c927 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlength_stats.sql @@ -0,0 +1,9 @@ +select min(cast(ar1.stratum_1 as int)) * 30 as min_value, + max(cast(ar1.stratum_1 as int)) * 30 as max_value, + 30 as interval_size +from @results_database_schema.ACHILLES_analysis aa1 +inner join @results_database_schema.ACHILLES_results ar1 on aa1.analysis_id = ar1.analysis_id, +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom +where aa1.analysis_id = 108 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlengthbyage.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlengthbyage.sql new file mode 100644 index 0000000000..f69160bcae --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlengthbyage.sql @@ -0,0 +1,10 @@ + select cast(cast(ard1.stratum_1 as int)*10 as varchar) + '-' + cast((cast(ard1.stratum_1 as int)+1)*10-1 as varchar) as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +where ard1.analysis_id = 107 diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlengthbygender.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlengthbygender.sql new file mode 100644 index 0000000000..1383c2bb88 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observationlengthbygender.sql @@ -0,0 +1,11 @@ +select c1.concept_name as category, + ard1.min_value as min_value, + ard1.p10_value as p10_value, + ard1.p25_value as p25_value, + ard1.median_value as median_value, + ard1.p75_value as p75_value, + ard1.p90_value as p90_value, + ard1.max_value as max_value +from @results_database_schema.ACHILLES_results_dist ard1 +inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) +where ard1.analysis_id = 106 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observedbymonth.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observedbymonth.sql new file mode 100644 index 0000000000..f4143f1c7f --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observedbymonth.sql @@ -0,0 +1,7 @@ +select cast(ar1.stratum_1 as int) as month_year, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 110) ar1, + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom + + \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observedbyyear_data.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observedbyyear_data.sql new file mode 100644 index 0000000000..084ac45880 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observedbyyear_data.sql @@ -0,0 +1,14 @@ +select cast(ar1.stratum_1 as int) - MinValue.MinValue as interval_index, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from +( + select * from @results_database_schema.ACHILLES_results where analysis_id = 109 +) ar1, +( + select min(cast(stratum_1 as int)) as MinValue + from @results_database_schema.ACHILLES_results where analysis_id = 109 +) MinValue, +( + select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +) denom \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observedbyyear_stats.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observedbyyear_stats.sql new file mode 100644 index 0000000000..048971af81 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/observedbyyear_stats.sql @@ -0,0 +1,5 @@ +select min(cast(ar1.stratum_1 as int)) as min_value, + max(cast(ar1.stratum_1 as int)) as max_value, + 1 as interval_size +from @results_database_schema.ACHILLES_results ar1 +where ar1.analysis_id = 109 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/periodsperperson.sql b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/periodsperperson.sql new file mode 100644 index 0000000000..67d048940d --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/observationperiod/periodsperperson.sql @@ -0,0 +1,5 @@ +select row_number() over (order by ar1.stratum_1) as concept_id, + ar1.stratum_1 as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 +where ar1.analysis_id = 113 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/person/ethnicity.sql b/src/main/resources/resources/cdmresults/sql/export_v5/person/ethnicity.sql new file mode 100644 index 0000000000..f6723341d0 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/person/ethnicity.sql @@ -0,0 +1,8 @@ +select c1.concept_id as concept_id, + c1.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join + @vocab_database_schema.concept c1 + on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) +where ar1.analysis_id = 5 diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/person/gender.sql b/src/main/resources/resources/cdmresults/sql/export_v5/person/gender.sql new file mode 100644 index 0000000000..f1587df99f --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/person/gender.sql @@ -0,0 +1,9 @@ +select c1.concept_id as concept_id, + c1.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join + @vocab_database_schema.concept c1 + on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) +where ar1.analysis_id = 2 +and c1.concept_id in (8507, 8532) \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/person/population.sql b/src/main/resources/resources/cdmresults/sql/export_v5/person/population.sql new file mode 100644 index 0000000000..62824ad453 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/person/population.sql @@ -0,0 +1,19 @@ +(select aa1.analysis_name as attribute_name, + ar1.stratum_1 as attribute_value +from @results_database_schema.ACHILLES_analysis aa1 +inner join +@results_database_schema.ACHILLES_results ar1 +on aa1.analysis_id = ar1.analysis_id +where aa1.analysis_id = 0 + +union + +select aa1.analysis_name as attribute_name, +cast(ar1.count_value as varchar) as attribute_value +from @results_database_schema.ACHILLES_analysis aa1 +inner join +@results_database_schema.ACHILLES_results ar1 +on aa1.analysis_id = ar1.analysis_id +where aa1.analysis_id = 1 +) +order by attribute_name desc diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/person/race.sql b/src/main/resources/resources/cdmresults/sql/export_v5/person/race.sql new file mode 100644 index 0000000000..d4fb85c52e --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/person/race.sql @@ -0,0 +1,8 @@ +select c1.concept_id as concept_id, + c1.concept_name as concept_name, + ar1.count_value as count_value +from @results_database_schema.ACHILLES_results ar1 + inner join + @vocab_database_schema.concept c1 + on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) +where ar1.analysis_id = 4 diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/person/yearofbirth_data.sql b/src/main/resources/resources/cdmresults/sql/export_v5/person/yearofbirth_data.sql new file mode 100644 index 0000000000..c70069eec4 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/person/yearofbirth_data.sql @@ -0,0 +1,7 @@ +select cast(ar1.stratum_1 as int) - MinValue.MinValue as interval_index, + ar1.count_value as count_value, + round(1.0*ar1.count_value / denom.count_value,5) as percent_value +from (select * from @results_database_schema.ACHILLES_results where analysis_id = 3) ar1, + (select min(cast(stratum_1 as int)) as MinValue from @results_database_schema.ACHILLES_results where analysis_id = 3) MinValue, + (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom +order by ar1.stratum_1 asc diff --git a/src/main/resources/resources/cdmresults/sql/export_v5/person/yearofbirth_stats.sql b/src/main/resources/resources/cdmresults/sql/export_v5/person/yearofbirth_stats.sql new file mode 100644 index 0000000000..63da3ee20d --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/export_v5/person/yearofbirth_stats.sql @@ -0,0 +1,5 @@ +select min(cast(ar1.stratum_1 as int)) as min_value, + max(cast(ar1.stratum_1 as int)) as max_value, + 1 as interval_size +from @results_database_schema.ACHILLES_results ar1 +where ar1.analysis_id = 3 diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/sqlAgeAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/export_v5/procedure/sqlAgeAtFirstOccurrence.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/procedure/sqlAgeAtFirstOccurrence.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/procedure/sqlAgeAtFirstOccurrence.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/export_v5/procedure/sqlPrevalenceByGenderAgeYear.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/procedure/sqlPrevalenceByGenderAgeYear.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/procedure/sqlPrevalenceByGenderAgeYear.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/export_v5/procedure/sqlPrevalenceByMonth.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/procedure/sqlPrevalenceByMonth.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/procedure/sqlPrevalenceByMonth.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/sqlProcedureTreemap.sql b/src/main/resources/resources/cdmresults/sql/export_v5/procedure/sqlProcedureTreemap.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/procedure/sqlProcedureTreemap.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/procedure/sqlProcedureTreemap.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/sqlProceduresByType.sql b/src/main/resources/resources/cdmresults/sql/export_v5/procedure/sqlProceduresByType.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/procedure/sqlProceduresByType.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/procedure/sqlProceduresByType.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/sqlAgeAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/export_v5/visit/sqlAgeAtFirstOccurrence.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/visit/sqlAgeAtFirstOccurrence.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/visit/sqlAgeAtFirstOccurrence.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/export_v5/visit/sqlPrevalenceByGenderAgeYear.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/visit/sqlPrevalenceByGenderAgeYear.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/visit/sqlPrevalenceByGenderAgeYear.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/export_v5/visit/sqlPrevalenceByMonth.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/visit/sqlPrevalenceByMonth.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/visit/sqlPrevalenceByMonth.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/sqlVisitDurationByType.sql b/src/main/resources/resources/cdmresults/sql/export_v5/visit/sqlVisitDurationByType.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/visit/sqlVisitDurationByType.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/visit/sqlVisitDurationByType.sql diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/sqlVisitTreemap.sql b/src/main/resources/resources/cdmresults/sql/export_v5/visit/sqlVisitTreemap.sql similarity index 100% rename from src/main/resources/resources/cdmresults/sql/report/visit/sqlVisitTreemap.sql rename to src/main/resources/resources/cdmresults/sql/export_v5/visit/sqlVisitTreemap.sql diff --git a/src/main/resources/resources/cdmresults/sql/getConceptDensity.sql b/src/main/resources/resources/cdmresults/sql/getConceptDensity.sql index 69fe5272a2..9bf3100a08 100644 --- a/src/main/resources/resources/cdmresults/sql/getConceptDensity.sql +++ b/src/main/resources/resources/cdmresults/sql/getConceptDensity.sql @@ -1,14 +1,18 @@ - select stratum_1 as CONCEPT_ID, max(count_value) as NUM_RECORDS - from @OHDSI_schema.ACHILLES_results - where analysis_id in (2, 4, 5, 201, 301, 401, 501, 505, 601, 701, 801, 901, 1001,1201) - and stratum_1 in (@conceptIdentifiers) - and stratum_1 <> '0' - group by stratum_1 - union - select stratum_2 as CONCEPT_ID, sum(count_value) as NUM_RECORDS - from @OHDSI_schema.ACHILLES_results - where analysis_id in (405, 605, 705, 805, 807) - and stratum_2 in (@conceptIdentifiers) - and stratum_2 <> '0' - group by stratum_2 +SELECT + stratum_1 AS CONCEPT_ID, + max(count_value) AS NUM_RECORDS +FROM @OHDSI_schema.ACHILLES_results +WHERE analysis_id IN (2, 4, 5, 201, 301, 401, 501, 505, 601, 701, 801, 901, 1001, 1201) +AND stratum_1 IN (@conceptIdentifiers) +AND stratum_1 <> '0' +GROUP BY stratum_1 +UNION +SELECT + stratum_2 AS CONCEPT_ID, + sum(count_value) AS NUM_RECORDS +FROM @OHDSI_schema.ACHILLES_results +WHERE analysis_id IN (405, 605, 705, 805, 807) +AND stratum_2 IN (@conceptIdentifiers) +AND stratum_2 <> '0' +GROUP BY stratum_2 diff --git a/src/main/resources/resources/cdmresults/sql/getConceptRecordCount.sql b/src/main/resources/resources/cdmresults/sql/getConceptRecordCount.sql index d0ce8afb68..fe317a1719 100644 --- a/src/main/resources/resources/cdmresults/sql/getConceptRecordCount.sql +++ b/src/main/resources/resources/cdmresults/sql/getConceptRecordCount.sql @@ -1,20 +1,25 @@ -with concepts as ( - select CAST(ancestor_concept_id as VARCHAR) ancestor_id, CAST(descendant_concept_id as VARCHAR) descendant_id - from @vocabularyTableQualifier.concept_ancestor ca - where ancestor_concept_id in (@conceptIdentifiers) -), counts as ( - select stratum_1 concept_id, max(count_value) agg_count_value - from @resultTableQualifier.achilles_results - where analysis_id in (2, 4, 5, 201, 301, 401, 501, 505, 601, 701, 801, 901, 1001,1201,1801) - group by stratum_1 - union - select stratum_2 as concept_id, sum(count_value) as agg_count_value - from @resultTableQualifier.achilles_results - where analysis_id in (405, 605, 705, 805, 807, 1805, 1807) - group by stratum_2 +WITH concepts AS ( + SELECT + CAST(ancestor_concept_id AS VARCHAR) ancestor_id, + CAST(descendant_concept_id AS VARCHAR) descendant_id + FROM @vocabularyTableQualifier.concept_ancestor ca + WHERE ancestor_concept_id IN (@conceptIdentifiers) +), counts AS ( +SELECT stratum_1 concept_id, MAX (count_value) agg_count_value +FROM @resultTableQualifier.achilles_results +WHERE analysis_id IN (2, 4, 5, 201, 301, 401, 501, 505, 601, 701, 801, 901, 1001, 1201, 1801) +GROUP BY stratum_1 +UNION +SELECT stratum_2 AS concept_id, SUM (count_value) AS agg_count_value +FROM @resultTableQualifier.achilles_results +WHERE analysis_id IN (405, 605, 705, 805, 807, 1805, 1807) +GROUP BY stratum_2 ) -select concepts.ancestor_id concept_id, isnull(max(c1.agg_count_value),0) record_count, isnull(sum(c2.agg_count_value),0) descendant_record_count -from concepts -left join counts c1 on concepts.ancestor_id = c1.concept_id -left join counts c2 on concepts.descendant_id = c2.concept_id -group by concepts.ancestor_id +SELECT + concepts.ancestor_id concept_id, + isnull(max(c1.agg_count_value), 0) record_count, + isnull(sum(c2.agg_count_value), 0) descendant_record_count +FROM concepts + LEFT JOIN counts c1 ON concepts.ancestor_id = c1.concept_id + LEFT JOIN counts c2 ON concepts.descendant_id = c2.concept_id +GROUP BY concepts.ancestor_id diff --git a/src/main/resources/resources/cdmresults/sql/getConditionOccurrenceTreemap.sql b/src/main/resources/resources/cdmresults/sql/getConditionOccurrenceTreemap.sql index 88f8440ed7..3a4c6b8a50 100644 --- a/src/main/resources/resources/cdmresults/sql/getConditionOccurrenceTreemap.sql +++ b/src/main/resources/resources/cdmresults/sql/getConditionOccurrenceTreemap.sql @@ -1,102 +1,122 @@ -select concept_hierarchy.concept_id, - isNull(concept_hierarchy.soc_concept_name,'NA') + '||' + isNull(concept_hierarchy.hlgt_concept_name,'NA') + '||' + isNull(concept_hierarchy.hlt_concept_name,'NA') + '||' + isNull(concept_hierarchy.pt_concept_name,'NA') + '||' + isNull(concept_hierarchy.snomed_concept_name,'NA') concept_path, hr1.count_value as num_persons, - round(1.0*hr1.count_value / denom.count_value,5) as percent_persons, - round(1.0*hr2.count_value / hr1.count_value,5) as records_per_person -from (select * from @ohdsi_database_schema.achilles_results where analysis_id = 400 ) hr1 - inner join - (select * from @ohdsi_database_schema.achilles_results where analysis_id = 401 ) hr2 - on hr1.stratum_1 = hr2.stratum_1 - inner join - ( - select snomed.concept_id, - snomed.concept_name as snomed_concept_name, - pt_to_hlt.pt_concept_name, - hlt_to_hlgt.hlt_concept_name, - hlgt_to_soc.hlgt_concept_name, - soc.concept_name as soc_concept_name - from - ( - select concept_id, concept_name - from @cdm_database_schema.concept - where vocabulary_id = 'SNOMED' - and concept_id in (@conceptIdList) - ) snomed - left join - (select c1.concept_id as snomed_concept_id, max(c2.concept_id) as pt_concept_id - from - @cdm_database_schema.concept c1 - inner join - @cdm_database_schema.concept_ancestor ca1 - on c1.concept_id = ca1.descendant_concept_id - and c1.vocabulary_id = 'SNOMED' - and ca1.min_levels_of_separation = 1 - inner join - @cdm_database_schema.concept c2 - on ca1.ancestor_concept_id = c2.concept_id - and c2.vocabulary_id = 'MedDRA' - group by c1.concept_id - ) snomed_to_pt - on snomed.concept_id = snomed_to_pt.snomed_concept_id +SELECT + concept_hierarchy.concept_id, + isNull(concept_hierarchy.soc_concept_name, 'NA') + '||' + isNull(concept_hierarchy.hlgt_concept_name, 'NA') + '||' + + isNull(concept_hierarchy.hlt_concept_name, 'NA') + '||' + isNull(concept_hierarchy.pt_concept_name, 'NA') + '||' + + isNull(concept_hierarchy.snomed_concept_name, 'NA') concept_path, + hr1.count_value AS num_persons, + round(1.0 * hr1.count_value / denom.count_value, 5) AS percent_persons, + round(1.0 * hr2.count_value / hr1.count_value, 5) AS records_per_person +FROM (SELECT * + FROM @ohdsi_database_schema.achilles_results WHERE analysis_id = 400) hr1 + INNER JOIN + (SELECT * + FROM @ohdsi_database_schema.achilles_results WHERE analysis_id = 401) hr2 + ON hr1.stratum_1 = hr2.stratum_1 + INNER JOIN + ( + SELECT + snomed.concept_id, + snomed.concept_name AS snomed_concept_name, + pt_to_hlt.pt_concept_name, + hlt_to_hlgt.hlt_concept_name, + hlgt_to_soc.hlgt_concept_name, + soc.concept_name AS soc_concept_name + FROM + ( + SELECT + concept_id, + concept_name + FROM @cdm_database_schema.concept + WHERE vocabulary_id = 'SNOMED' + AND concept_id IN (@conceptIdList) + ) snomed + LEFT JOIN + (SELECT + c1.concept_id AS snomed_concept_id, + max(c2.concept_id) AS pt_concept_id + FROM + @cdm_database_schema.concept c1 + INNER JOIN + @cdm_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'SNOMED' + AND ca1.min_levels_of_separation = 1 + INNER JOIN + @cdm_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'MedDRA' + GROUP BY c1.concept_id + ) snomed_to_pt + ON snomed.concept_id = snomed_to_pt.snomed_concept_id - left join - (select c1.concept_id as pt_concept_id, c1.concept_name as pt_concept_name, max(c2.concept_id) as hlt_concept_id - from - @cdm_database_schema.concept c1 - inner join - @cdm_database_schema.concept_ancestor ca1 - on c1.concept_id = ca1.descendant_concept_id - and c1.vocabulary_id = 'MedDRA' - and ca1.min_levels_of_separation = 1 - inner join - @cdm_database_schema.concept c2 - on ca1.ancestor_concept_id = c2.concept_id - and c2.vocabulary_id = 'MedDRA' - group by c1.concept_id, c1.concept_name - ) pt_to_hlt - on snomed_to_pt.pt_concept_id = pt_to_hlt.pt_concept_id + LEFT JOIN + (SELECT + c1.concept_id AS pt_concept_id, + c1.concept_name AS pt_concept_name, + max(c2.concept_id) AS hlt_concept_id + FROM + @cdm_database_schema.concept c1 + INNER JOIN + @cdm_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'MedDRA' + AND ca1.min_levels_of_separation = 1 + INNER JOIN + @cdm_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'MedDRA' + GROUP BY c1.concept_id, c1.concept_name + ) pt_to_hlt + ON snomed_to_pt.pt_concept_id = pt_to_hlt.pt_concept_id - left join - (select c1.concept_id as hlt_concept_id, c1.concept_name as hlt_concept_name, max(c2.concept_id) as hlgt_concept_id - from - @cdm_database_schema.concept c1 - inner join - @cdm_database_schema.concept_ancestor ca1 - on c1.concept_id = ca1.descendant_concept_id - and c1.vocabulary_id = 'MedDRA' - and ca1.min_levels_of_separation = 1 - inner join - @cdm_database_schema.concept c2 - on ca1.ancestor_concept_id = c2.concept_id - and c2.vocabulary_id = 'MedDRA' - group by c1.concept_id, c1.concept_name - ) hlt_to_hlgt - on pt_to_hlt.hlt_concept_id = hlt_to_hlgt.hlt_concept_id + LEFT JOIN + (SELECT + c1.concept_id AS hlt_concept_id, + c1.concept_name AS hlt_concept_name, + max(c2.concept_id) AS hlgt_concept_id + FROM + @cdm_database_schema.concept c1 + INNER JOIN + @cdm_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'MedDRA' + AND ca1.min_levels_of_separation = 1 + INNER JOIN + @cdm_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'MedDRA' + GROUP BY c1.concept_id, c1.concept_name + ) hlt_to_hlgt + ON pt_to_hlt.hlt_concept_id = hlt_to_hlgt.hlt_concept_id - left join - (select c1.concept_id as hlgt_concept_id, c1.concept_name as hlgt_concept_name, max(c2.concept_id) as soc_concept_id - from - @cdm_database_schema.concept c1 - inner join - @cdm_database_schema.concept_ancestor ca1 - on c1.concept_id = ca1.descendant_concept_id - and c1.vocabulary_id = 'MedDRA' - and ca1.min_levels_of_separation = 1 - inner join - @cdm_database_schema.concept c2 - on ca1.ancestor_concept_id = c2.concept_id - and c2.vocabulary_id = 'MedDRA' - group by c1.concept_id, c1.concept_name - ) hlgt_to_soc - on hlt_to_hlgt.hlgt_concept_id = hlgt_to_soc.hlgt_concept_id + LEFT JOIN + (SELECT + c1.concept_id AS hlgt_concept_id, + c1.concept_name AS hlgt_concept_name, + max(c2.concept_id) AS soc_concept_id + FROM + @cdm_database_schema.concept c1 + INNER JOIN + @cdm_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'MedDRA' + AND ca1.min_levels_of_separation = 1 + INNER JOIN + @cdm_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'MedDRA' + GROUP BY c1.concept_id, c1.concept_name + ) hlgt_to_soc + ON hlt_to_hlgt.hlgt_concept_id = hlgt_to_soc.hlgt_concept_id - left join @cdm_database_schema.concept soc - on hlgt_to_soc.soc_concept_id = soc.concept_id + LEFT JOIN @cdm_database_schema.concept soc + ON hlgt_to_soc.soc_concept_id = soc.concept_id + ) concept_hierarchy + ON hr1.stratum_1 = CAST(concept_hierarchy.concept_id AS VARCHAR(255)) + , + (SELECT count_value + FROM @ohdsi_database_schema.achilles_results WHERE analysis_id = 1) denom - ) concept_hierarchy - on hr1.stratum_1 = CAST(concept_hierarchy.concept_id as VARCHAR(255)) - , - (select count_value from @ohdsi_database_schema.achilles_results where analysis_id = 1 ) denom - -order by hr1.count_value desc +ORDER BY hr1.count_value DESC diff --git a/src/main/resources/resources/cdmresults/sql/getDrugEraPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/getDrugEraPrevalenceByGenderAgeYear.sql index 74d080c34d..f2ea6c6284 100644 --- a/src/main/resources/resources/cdmresults/sql/getDrugEraPrevalenceByGenderAgeYear.sql +++ b/src/main/resources/resources/cdmresults/sql/getDrugEraPrevalenceByGenderAgeYear.sql @@ -1,34 +1,40 @@ -SELECT c1.concept_id AS concept_id, - cast(num_stratum_4 * 10 AS VARCHAR) + '-' + cast((num_stratum_4 + 1) * 10 - 1 AS VARCHAR) AS trellis_name, --age decile - c2.concept_name AS series_name, --gender - num_stratum_2 AS x_calendar_year, -- calendar year, note, there could be blanks - ROUND(1000 * (1.0 * num_count_value / denom_count_value), 5) AS y_prevalence_1000pp --prevalence, per 1000 persons +SELECT + c1.concept_id AS concept_id, + cast(num_stratum_4 * 10 AS VARCHAR) + '-' + cast((num_stratum_4 + 1) * 10 - 1 AS VARCHAR) AS trellis_name, + --age decile + c2.concept_name AS series_name, + --gender + num_stratum_2 AS x_calendar_year, + -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), + 5) AS y_prevalence_1000pp --prevalence, per 1000 persons FROM ( - SELECT num.stratum_1 num_stratum_1, - CAST(num.stratum_2 AS INT) AS num_stratum_2, - num.stratum_3 num_stratum_3, - CAST(num.stratum_4 AS INT) AS num_stratum_4, - num.count_value AS num_count_value, - denom.count_value AS denom_count_value - FROM ( - SELECT * - FROM @ohdsi_database_schema.achilles_results - WHERE analysis_id = 904 - AND stratum_3 IN ('8507', '8532') - ) num - INNER JOIN ( - SELECT * - FROM @ohdsi_database_schema.achilles_results - WHERE analysis_id = 116 - AND stratum_2 IN ('8507', '8532') - ) denom - ON num.stratum_2 = denom.stratum_1 - AND num.stratum_3 = denom.stratum_2 - AND num.stratum_4 = denom.stratum_3 - ) tmp -INNER JOIN @vocabulary_database_schema.concept c1 - ON num_stratum_1 = CAST(c1.concept_id as VARCHAR) + SELECT + num.stratum_1 num_stratum_1, + CAST(num.stratum_2 AS INT) AS num_stratum_2, + num.stratum_3 num_stratum_3, + CAST(num.stratum_4 AS INT) AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @ohdsi_database_schema.achilles_results + WHERE analysis_id = 904 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @ohdsi_database_schema.achilles_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp + INNER JOIN @vocabulary_database_schema.concept c1 +ON num_stratum_1 = CAST(c1.concept_id AS VARCHAR ) INNER JOIN @vocabulary_database_schema.concept c2 - ON num_stratum_3 = CAST(c2.concept_id as VARCHAR) +ON num_stratum_3 = CAST(c2.concept_id AS VARCHAR ) WHERE c1.concept_id = @conceptId -ORDER BY c1.concept_id, num_stratum_2 +ORDER BY c1.concept_id, num_stratum_2 diff --git a/src/main/resources/resources/cdmresults/sql/getDrugEraTreemap.sql b/src/main/resources/resources/cdmresults/sql/getDrugEraTreemap.sql index 2d7677de15..4def188a03 100644 --- a/src/main/resources/resources/cdmresults/sql/getDrugEraTreemap.sql +++ b/src/main/resources/resources/cdmresults/sql/getDrugEraTreemap.sql @@ -1,92 +1,108 @@ -select concept_hierarchy.rxnorm_ingredient_concept_id concept_id, - isnull(concept_hierarchy.atc1_concept_name,'NA') + '||' + - isnull(concept_hierarchy.atc3_concept_name,'NA') + '||' + - isnull(concept_hierarchy.atc5_concept_name,'NA') + '||' + - isnull(concept_hierarchy.rxnorm_ingredient_concept_name,'||') concept_path, - hr1.count_value as num_persons, - 1.0*hr1.count_value / denom.count_value as percent_persons, - hr2.avg_value as length_of_era -from (select * from @ohdsi_database_schema.achilles_results where analysis_id = 900 ) hr1 - inner join - (select stratum_1, avg_value from @ohdsi_database_schema.achilles_results_dist where analysis_id = 907 ) hr2 - on hr1.stratum_1 = hr2.stratum_1 - inner join - ( - select rxnorm.rxnorm_ingredient_concept_id, - rxnorm.rxnorm_ingredient_concept_name, - atc5_to_atc3.atc5_concept_name, - atc3_to_atc1.atc3_concept_name, - atc1.concept_name as atc1_concept_name - from - ( - select c2.concept_id as rxnorm_ingredient_concept_id, - c2.concept_name as RxNorm_ingredient_concept_name - from - @vocabulary_database_schema.concept c2 - where - c2.vocabulary_id = 'RxNorm' - and c2.concept_class_id = 'Ingredient' - and c2.concept_id in (@conceptList) - ) rxnorm - left join - (select c1.concept_id as rxnorm_ingredient_concept_id, max(c2.concept_id) as atc5_concept_id - from - @vocabulary_database_schema.concept c1 - inner join - @vocabulary_database_schema.concept_ancestor ca1 - on c1.concept_id = ca1.descendant_concept_id - and c1.vocabulary_id = 'RxNorm' - and c1.concept_class_id = 'Ingredient' - inner join - @vocabulary_database_schema.concept c2 - on ca1.ancestor_concept_id = c2.concept_id - and c2.vocabulary_id = 'ATC' - and c2.concept_class_id = 'ATC 4th' - where c1.concept_id in (@conceptList) - group by c1.concept_id - ) rxnorm_to_atc5 - on rxnorm.rxnorm_ingredient_concept_id = rxnorm_to_atc5.rxnorm_ingredient_concept_id +SELECT + concept_hierarchy.rxnorm_ingredient_concept_id concept_id, + isnull(concept_hierarchy.atc1_concept_name, 'NA') + '||' + + isnull(concept_hierarchy.atc3_concept_name, 'NA') + '||' + + isnull(concept_hierarchy.atc5_concept_name, 'NA') + '||' + + isnull(concept_hierarchy.rxnorm_ingredient_concept_name, '||') concept_path, + hr1.count_value AS num_persons, + 1.0 * hr1.count_value / denom.count_value AS percent_persons, + hr2.avg_value AS length_of_era +FROM (SELECT * + FROM @ohdsi_database_schema.achilles_results WHERE analysis_id = 900) hr1 + INNER JOIN + (SELECT + stratum_1, + avg_value + FROM @ohdsi_database_schema.achilles_results_dist WHERE analysis_id = 907) hr2 + ON hr1.stratum_1 = hr2.stratum_1 + INNER JOIN + ( + SELECT + rxnorm.rxnorm_ingredient_concept_id, + rxnorm.rxnorm_ingredient_concept_name, + atc5_to_atc3.atc5_concept_name, + atc3_to_atc1.atc3_concept_name, + atc1.concept_name AS atc1_concept_name + FROM + ( + SELECT + c2.concept_id AS rxnorm_ingredient_concept_id, + c2.concept_name AS RxNorm_ingredient_concept_name + FROM + @vocabulary_database_schema.concept c2 + WHERE + c2.vocabulary_id = 'RxNorm' + AND c2.concept_class_id = 'Ingredient' + AND c2.concept_id IN (@conceptList) + ) rxnorm + LEFT JOIN + (SELECT + c1.concept_id AS rxnorm_ingredient_concept_id, + max(c2.concept_id) AS atc5_concept_id + FROM + @vocabulary_database_schema.concept c1 + INNER JOIN + @vocabulary_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'RxNorm' + AND c1.concept_class_id = 'Ingredient' + INNER JOIN + @vocabulary_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'ATC' + AND c2.concept_class_id = 'ATC 4th' + WHERE c1.concept_id IN (@conceptList) + GROUP BY c1.concept_id + ) rxnorm_to_atc5 + ON rxnorm.rxnorm_ingredient_concept_id = rxnorm_to_atc5.rxnorm_ingredient_concept_id - left join - (select c1.concept_id as atc5_concept_id, c1.concept_name as atc5_concept_name, max(c2.concept_id) as atc3_concept_id - from - @vocabulary_database_schema.concept c1 - inner join - @vocabulary_database_schema.concept_ancestor ca1 - on c1.concept_id = ca1.descendant_concept_id - and c1.vocabulary_id = 'ATC' - and c1.concept_class_id = 'ATC 4th' - inner join - @vocabulary_database_schema.concept c2 - on ca1.ancestor_concept_id = c2.concept_id - and c2.vocabulary_id = 'ATC' - and c2.concept_class_id = 'ATC 2nd' - group by c1.concept_id, c1.concept_name - ) atc5_to_atc3 - on rxnorm_to_atc5.atc5_concept_id = atc5_to_atc3.atc5_concept_id + LEFT JOIN + (SELECT + c1.concept_id AS atc5_concept_id, + c1.concept_name AS atc5_concept_name, + max(c2.concept_id) AS atc3_concept_id + FROM + @vocabulary_database_schema.concept c1 + INNER JOIN + @vocabulary_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'ATC' + AND c1.concept_class_id = 'ATC 4th' + INNER JOIN + @vocabulary_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'ATC' + AND c2.concept_class_id = 'ATC 2nd' + GROUP BY c1.concept_id, c1.concept_name + ) atc5_to_atc3 + ON rxnorm_to_atc5.atc5_concept_id = atc5_to_atc3.atc5_concept_id - left join - (select c1.concept_id as atc3_concept_id, c1.concept_name as atc3_concept_name, max(c2.concept_id) as atc1_concept_id - from - @vocabulary_database_schema.concept c1 - inner join - @vocabulary_database_schema.concept_ancestor ca1 - on c1.concept_id = ca1.descendant_concept_id - and c1.vocabulary_id = 'ATC' - and c1.concept_class_id = 'ATC 2nd' - inner join - @vocabulary_database_schema.concept c2 - on ca1.ancestor_concept_id = c2.concept_id - and c2.vocabulary_id = 'ATC' - and c2.concept_class_id = 'ATC 1st' - group by c1.concept_id, c1.concept_name - ) atc3_to_atc1 - on atc5_to_atc3.atc3_concept_id = atc3_to_atc1.atc3_concept_id + LEFT JOIN + (SELECT + c1.concept_id AS atc3_concept_id, + c1.concept_name AS atc3_concept_name, + max(c2.concept_id) AS atc1_concept_id + FROM + @vocabulary_database_schema.concept c1 + INNER JOIN + @vocabulary_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'ATC' + AND c1.concept_class_id = 'ATC 2nd' + INNER JOIN + @vocabulary_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'ATC' + AND c2.concept_class_id = 'ATC 1st' + GROUP BY c1.concept_id, c1.concept_name + ) atc3_to_atc1 + ON atc5_to_atc3.atc3_concept_id = atc3_to_atc1.atc3_concept_id - left join @vocabulary_database_schema.concept atc1 - on atc3_to_atc1.atc1_concept_id = atc1.concept_id - ) concept_hierarchy - on hr1.stratum_1 = CAST(concept_hierarchy.rxnorm_ingredient_concept_id AS VARCHAR) - , - (select count_value from @ohdsi_database_schema.achilles_results where analysis_id = 1 ) denom -order by hr1.count_value desc + LEFT JOIN @vocabulary_database_schema.concept atc1 + ON atc3_to_atc1.atc1_concept_id = atc1.concept_id + ) concept_hierarchy + ON hr1.stratum_1 = CAST(concept_hierarchy.rxnorm_ingredient_concept_id AS VARCHAR) + , + (SELECT count_value + FROM @ohdsi_database_schema.achilles_results WHERE analysis_id = 1) denom +ORDER BY hr1.count_value DESC diff --git a/src/main/resources/resources/cdmresults/sql/getMonthlyConditionOccurrencePrevalence.sql b/src/main/resources/resources/cdmresults/sql/getMonthlyConditionOccurrencePrevalence.sql index 471d5e2407..ad4f281a75 100644 --- a/src/main/resources/resources/cdmresults/sql/getMonthlyConditionOccurrencePrevalence.sql +++ b/src/main/resources/resources/cdmresults/sql/getMonthlyConditionOccurrencePrevalence.sql @@ -1,14 +1,20 @@ -select num.stratum_2 as x_calendar_month, - round(1000*(1.0*num.count_value/denom.count_value),5) as y_prevalence_1000pp -from ( - select stratum_1, stratum_2, count_value - from @OHDSI_schema.ACHILLES_results - where analysis_id = 402 and stratum_1 = '@conceptId' -) num -inner join ( - select stratum_1, count_value - from @OHDSI_schema.ACHILLES_results - where analysis_id = 117 -) denom -on num.stratum_2 = denom.stratum_1 -order by cast(num.stratum_2 as int) \ No newline at end of file +SELECT + num.stratum_2 AS x_calendar_month, + round(1000 * (1.0 * num.count_value / denom.count_value), 5) AS y_prevalence_1000pp +FROM ( + SELECT + stratum_1, + stratum_2, + count_value + FROM @OHDSI_schema.ACHILLES_results + WHERE analysis_id = 402 AND stratum_1 = '@conceptId' + ) num + INNER JOIN ( + SELECT + stratum_1, + count_value + FROM @OHDSI_schema.ACHILLES_results + WHERE analysis_id = 117 + ) denom + ON num.stratum_2 = denom.stratum_1 +ORDER BY cast(num.stratum_2 AS INT) \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/achillesheel/sqlAchillesHeel.sql b/src/main/resources/resources/cdmresults/sql/report/achillesheel/sqlAchillesHeel.sql index 5ce0602ea8..28eb5d0930 100644 --- a/src/main/resources/resources/cdmresults/sql/report/achillesheel/sqlAchillesHeel.sql +++ b/src/main/resources/resources/cdmresults/sql/report/achillesheel/sqlAchillesHeel.sql @@ -1,3 +1,5 @@ -select analysis_id as AttributeName, ACHILLES_HEEL_warning as AttributeValue -from @results_database_schema.ACHILLES_HEEL_results -order by case when left(ACHILLES_HEEL_warning,5) = 'Error' then 1 else 2 end, analysis_id \ No newline at end of file +SELECT + analysis_id AS "attribute_name", + ACHILLES_HEEL_warning AS "attribute_value" +FROM @results_database_schema.ACHILLES_HEEL_results +ORDER BY CASE WHEN LEFT(ACHILLES_HEEL_warning, 5) = 'Error' THEN 1 ELSE 2 END , analysis_id \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/drilldown/ageAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/report/condition/drilldown/ageAtFirstOccurrence.sql new file mode 100644 index 0000000000..d0c5152855 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/condition/drilldown/ageAtFirstOccurrence.sql @@ -0,0 +1,19 @@ +SELECT + c1.concept_id AS "conceptId", + c2.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN +@vocab_database_schema.concept c2 +ON ard1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 406 +AND c1.concept_id = @conceptId \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/drilldown/byType.sql b/src/main/resources/resources/cdmresults/sql/report/condition/drilldown/byType.sql new file mode 100644 index 0000000000..1f7b0a3977 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/condition/drilldown/byType.sql @@ -0,0 +1,40 @@ +SELECT + c1.concept_id AS "conditionConceptId", + c1.concept_name AS "conditionConceptName", + c2.concept_group_id AS "conceptId", + c2.concept_group_name AS "conceptName", + sum(ar1.count_value) AS "countValue" +FROM @results_database_schema.ACHILLES_results ar1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ar1.stratum_1 = cast(c1.concept_id AS VARCHAR ) +INNER JOIN +( +SELECT concept_id, +CASE WHEN concept_name LIKE 'Inpatient%' THEN 10 +WHEN concept_name LIKE 'Outpatient%' THEN 20 +ELSE concept_id END ++ +CASE WHEN (concept_name LIKE 'Inpatient%' OR concept_name LIKE 'Outpatient%' ) AND (concept_name LIKE '%primary%' OR concept_name LIKE '%1st position%') THEN 1 +WHEN (concept_name LIKE 'Inpatient%' OR concept_name LIKE 'Outpatient%' ) AND (concept_name NOT LIKE '%primary%' AND concept_name NOT LIKE '%1st position%') THEN 2 +ELSE 0 END AS concept_group_id, +CASE WHEN concept_name LIKE 'Inpatient%' THEN 'Claim- Inpatient: ' +WHEN concept_name LIKE 'Outpatient%' THEN 'Claim- Outpatient: ' +ELSE concept_name END ++ +'' ++ +CASE WHEN (concept_name LIKE 'Inpatient%' OR concept_name LIKE 'Outpatient%' ) AND (concept_name LIKE '%primary%' OR concept_name LIKE '%1st position%') THEN 'Primary diagnosis' +WHEN (concept_name LIKE 'Inpatient%' OR concept_name LIKE 'Outpatient%' ) AND (concept_name NOT LIKE '%primary%' AND concept_name NOT LIKE '%1st position%') THEN 'Secondary diagnosis' +ELSE '' END AS concept_group_name +FROM @vocab_database_schema.concept +WHERE lower(vocabulary_id) = 'condition type' + +) c2 +ON ar1.stratum_2 = cast(c2.concept_id AS VARCHAR ) +WHERE ar1.analysis_id = 405 +AND CAST(ar1.stratum_1 AS INT) = @conceptId +GROUP BY c1.concept_id, +c1.concept_name, +c2.concept_group_id, +c2.concept_group_name \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/drilldown/prevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/condition/drilldown/prevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..256c3da8da --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/condition/drilldown/prevalenceByGenderAgeYear.sql @@ -0,0 +1,43 @@ +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptName", + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS + VARCHAR) AS "trellisName", + --age decile + c2.concept_name AS "seriesName", + --gender + CAST(num_stratum_2 AS INT) AS "xCalendarYear", + -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), + 5) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM ( + SELECT + num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 404 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp + INNER JOIN @vocab_database_schema.concept c1 +ON num_stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 +ON num_stratum_3 = CAST(c2.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId +ORDER BY c1.concept_id, +num_stratum_2 diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/drilldown/prevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/condition/drilldown/prevalenceByMonth.sql new file mode 100644 index 0000000000..f723898aca --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/condition/drilldown/prevalenceByMonth.sql @@ -0,0 +1,26 @@ +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptName", + num.stratum_2 AS "xCalendarMonth", + -- calendar year, note, there could be blanks + round(1000 * (1.0 * num.count_value / denom.count_value), 5) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM + (SELECT + CAST(stratum_1 AS INT) stratum_1, + CAST(stratum_2 AS INT) stratum_2, + count_value + FROM + @results_database_schema.ACHILLES_results WHERE analysis_id = 402 GROUP BY analysis_id, stratum_1, stratum_2, count_value) num + INNER JOIN + (SELECT + CAST(stratum_1 AS INT) stratum_1, + count_value + FROM + @results_database_schema.ACHILLES_results WHERE analysis_id = 117 GROUP BY analysis_id, stratum_1, count_value) denom + ON num.stratum_2 = denom.stratum_1 + --calendar year + INNER JOIN + @vocab_database_schema.concept c1 +ON num.stratum_1 = c1.concept_id +WHERE c1.concept_id = @conceptId +ORDER BY CAST(num.stratum_2 AS INT) \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/condition/treemap.sql b/src/main/resources/resources/cdmresults/sql/report/condition/treemap.sql new file mode 100644 index 0000000000..c7a02713da --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/condition/treemap.sql @@ -0,0 +1,119 @@ +SELECT + concept_hierarchy.concept_id AS "conceptId", + isNull(concept_hierarchy.soc_concept_name, 'NA') + '||' + isNull(concept_hierarchy.hlgt_concept_name, 'NA') + '||' + + isNull(concept_hierarchy.hlt_concept_name, 'NA') + '||' + isNull(concept_hierarchy.pt_concept_name, 'NA') + '||' + + isNull(concept_hierarchy.snomed_concept_name, 'NA') AS "conceptPath", + ar1.count_value AS "numPersons", + round(1.0 * ar1.count_value / denom.count_value, 5) AS "percentPersons", + round(1.0 * ar2.count_value / ar1.count_value, 5) AS "recordsPerPerson" +FROM (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 400) ar1 + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 401) ar2 + ON ar1.stratum_1 = ar2.stratum_1 + INNER JOIN + ( + SELECT + snomed.concept_id, + snomed.concept_name AS snomed_concept_name, + pt_to_hlt.pt_concept_name, + hlt_to_hlgt.hlt_concept_name, + hlgt_to_soc.hlgt_concept_name, + soc.concept_name AS soc_concept_name + FROM + ( + SELECT + concept_id, + concept_name + FROM @vocab_database_schema.concept + WHERE domain_id = 'Condition' + ) snomed + LEFT JOIN + (SELECT + c1.concept_id AS snomed_concept_id, + max(c2.concept_id) AS pt_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.domain_id = 'Condition' + AND ca1.min_levels_of_separation = 1 + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'MedDRA' + GROUP BY c1.concept_id + ) snomed_to_pt + ON snomed.concept_id = snomed_to_pt.snomed_concept_id + + LEFT JOIN + (SELECT + c1.concept_id AS pt_concept_id, + c1.concept_name AS pt_concept_name, + max(c2.concept_id) AS hlt_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'MedDRA' + AND ca1.min_levels_of_separation = 1 + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'MedDRA' + GROUP BY c1.concept_id, c1.concept_name + ) pt_to_hlt + ON snomed_to_pt.pt_concept_id = pt_to_hlt.pt_concept_id + + LEFT JOIN + (SELECT + c1.concept_id AS hlt_concept_id, + c1.concept_name AS hlt_concept_name, + max(c2.concept_id) AS hlgt_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'MedDRA' + AND ca1.min_levels_of_separation = 1 + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'MedDRA' + GROUP BY c1.concept_id, c1.concept_name + ) hlt_to_hlgt + ON pt_to_hlt.hlt_concept_id = hlt_to_hlgt.hlt_concept_id + + LEFT JOIN + (SELECT + c1.concept_id AS hlgt_concept_id, + c1.concept_name AS hlgt_concept_name, + max(c2.concept_id) AS soc_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'MedDRA' + AND ca1.min_levels_of_separation = 1 + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'MedDRA' + GROUP BY c1.concept_id, c1.concept_name + ) hlgt_to_soc + ON hlt_to_hlgt.hlgt_concept_id = hlgt_to_soc.hlgt_concept_id + + LEFT JOIN @vocab_database_schema.concept soc + ON hlgt_to_soc.soc_concept_id = soc.concept_id + ) concept_hierarchy + ON ar1.stratum_1 = CAST(concept_hierarchy.concept_id AS VARCHAR) + , + (SELECT count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1) denom + +ORDER BY ar1.count_value DESC diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/ageAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/ageAtFirstOccurrence.sql new file mode 100644 index 0000000000..43543e4578 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/ageAtFirstOccurrence.sql @@ -0,0 +1,18 @@ +SELECT + c1.concept_id AS "conceptId", + c2.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN @vocab_database_schema.concept c1 +ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 +ON ard1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 1006 +AND c1.concept_id = @conceptId +AND ard1.count_value > 0 diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/lengthOfEra.sql b/src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/lengthOfEra.sql new file mode 100644 index 0000000000..11165d2f84 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/lengthOfEra.sql @@ -0,0 +1,15 @@ +SELECT + c1.concept_id AS "conceptId", + 'Length of era' AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN @vocab_database_schema.concept c1 ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 1007 AND ard1.count_value > 0 + + diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/prevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/prevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..954d87e560 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/prevalenceByGenderAgeYear.sql @@ -0,0 +1,42 @@ +SELECT + c1.concept_id AS "conceptId", + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS + VARCHAR) AS "trellisName", + --age decile + c2.concept_name AS "seriesName", + --gender + CAST(num_stratum_2 AS INT) AS "xCalendarYear", + -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), + 5) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM ( + SELECT + num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 1004 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp + INNER JOIN @vocab_database_schema.concept c1 +ON num_stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 +ON num_stratum_3 = CAST(c2.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId +ORDER BY c1.concept_id, +num_stratum_2 diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/prevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/prevalenceByMonth.sql new file mode 100644 index 0000000000..2ba4ffff26 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/conditionera/drilldown/prevalenceByMonth.sql @@ -0,0 +1,15 @@ +SELECT + c1.concept_id AS "conceptId", + num.stratum_2 AS "xCalendarMonth", + round(1000 * (1.0 * num.count_value / denom.count_value), 5) AS "yPrevalence1000Pp" +FROM + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1002) num + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 117) denom + ON num.stratum_2 = denom.stratum_1 + --calendar year + INNER JOIN + @vocab_database_schema.concept c1 ON num.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/conditionera/treemap.sql b/src/main/resources/resources/cdmresults/sql/report/conditionera/treemap.sql new file mode 100644 index 0000000000..de46ae283f --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/conditionera/treemap.sql @@ -0,0 +1,122 @@ +SELECT + concept_hierarchy.concept_id AS "conceptId", + isNull(concept_hierarchy.soc_concept_name, 'NA') + '||' + isNull(concept_hierarchy.hlgt_concept_name, 'NA') + '||' + + isNull(concept_hierarchy.hlt_concept_name, 'NA') + '||' + isNull(concept_hierarchy.pt_concept_name, 'NA') + '||' + + isNull(concept_hierarchy.snomed_concept_name, 'NA') AS "conceptPath", + ar1.count_value AS "numPersons", + ROUND(1.0 * ar1.count_value / denom.count_value, 5) AS "percentPersons", + ROUND(ar2.avg_value, 5) AS "lengthOfEra" +FROM (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1000) ar1 + INNER JOIN + (SELECT + stratum_1, + avg_value + FROM @results_database_schema.ACHILLES_results_dist WHERE analysis_id = 1007) ar2 + ON ar1.stratum_1 = ar2.stratum_1 + INNER JOIN + ( + SELECT + snomed.concept_id, + snomed.concept_name AS snomed_concept_name, + pt_to_hlt.pt_concept_name, + hlt_to_hlgt.hlt_concept_name, + hlgt_to_soc.hlgt_concept_name, + soc.concept_name AS soc_concept_name + FROM + ( + SELECT + concept_id, + concept_name + FROM @vocab_database_schema.concept + WHERE domain_id = 'Condition' + ) snomed + LEFT JOIN + (SELECT + c1.concept_id AS snomed_concept_id, + max(c2.concept_id) AS pt_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.domain_id = 'Condition' + AND ca1.min_levels_of_separation = 1 + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'MedDRA' + GROUP BY c1.concept_id + ) snomed_to_pt + ON snomed.concept_id = snomed_to_pt.snomed_concept_id + + LEFT JOIN + (SELECT + c1.concept_id AS pt_concept_id, + c1.concept_name AS pt_concept_name, + max(c2.concept_id) AS hlt_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'MedDRA' + AND ca1.min_levels_of_separation = 1 + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'MedDRA' + GROUP BY c1.concept_id, c1.concept_name + ) pt_to_hlt + ON snomed_to_pt.pt_concept_id = pt_to_hlt.pt_concept_id + + LEFT JOIN + (SELECT + c1.concept_id AS hlt_concept_id, + c1.concept_name AS hlt_concept_name, + max(c2.concept_id) AS hlgt_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'MedDRA' + AND ca1.min_levels_of_separation = 1 + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'MedDRA' + GROUP BY c1.concept_id, c1.concept_name + ) hlt_to_hlgt + ON pt_to_hlt.hlt_concept_id = hlt_to_hlgt.hlt_concept_id + + LEFT JOIN + (SELECT + c1.concept_id AS hlgt_concept_id, + c1.concept_name AS hlgt_concept_name, + max(c2.concept_id) AS soc_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'MedDRA' + AND ca1.min_levels_of_separation = 1 + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'MedDRA' + GROUP BY c1.concept_id, c1.concept_name + ) hlgt_to_soc + ON hlt_to_hlgt.hlgt_concept_id = hlgt_to_soc.hlgt_concept_id + + LEFT JOIN @vocab_database_schema.concept soc + ON hlgt_to_soc.soc_concept_id = soc.concept_id + + + ) concept_hierarchy + ON ar1.stratum_1 = cAST(concept_hierarchy.concept_id AS VARCHAR) + , + (SELECT count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1) denom +ORDER BY ar1.count_value DESC \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/datadensity/conceptsperperson.sql b/src/main/resources/resources/cdmresults/sql/report/datadensity/conceptsperperson.sql index b39918d883..95e3330518 100644 --- a/src/main/resources/resources/cdmresults/sql/report/datadensity/conceptsperperson.sql +++ b/src/main/resources/resources/cdmresults/sql/report/datadensity/conceptsperperson.sql @@ -1,76 +1,82 @@ -select 'Condition occurrence' as Category, - ard1.min_value as min_value, - ard1.p10_value as p10_value, - ard1.p25_value as p25_value, - ard1.median_value as median_value, - ard1.p75_value as p75_value, - ard1.p90_value as p90_value, - ard1.max_value as max_value -from @results_database_schema.ACHILLES_results_dist ard1 -where ard1.analysis_id = 403 +SELECT + 'Condition occurrence' AS "category", + ard1.min_Value AS "min_Value", + ard1.p10_Value AS "p10_Value", + ard1.p25_Value AS "p25_Value", + ard1.median_Value AS "median_Value", + ard1.p75_Value AS "p75_Value", + ard1.p90_Value AS "p90_Value", + ard1.max_Value AS "max_Value" +FROM @results_database_schema.ACHILLES_results_dist ard1 +WHERE ard1.analysis_id = 403 -union +UNION -select 'Procedure occurrence' as Category, - ard1.min_value as min_value, - ard1.p10_value as p10_value, - ard1.p25_value as p25_value, - ard1.median_value as median_value, - ard1.p75_value as p75_value, - ard1.p90_value as p90_value, - ard1.max_value as max_value -from @results_database_schema.ACHILLES_results_dist ard1 -where ard1.analysis_id = 603 +SELECT + 'Procedure occurrence' AS "category", + ard1.min_Value AS "min_Value", + ard1.p10_Value AS "p10_Value", + ard1.p25_Value AS "p25_Value", + ard1.median_Value AS "median_Value", + ard1.p75_Value AS "p75_Value", + ard1.p90_Value AS "p90_Value", + ard1.max_Value AS "max_Value" +FROM @results_database_schema.ACHILLES_results_dist ard1 +WHERE ard1.analysis_id = 603 -union +UNION -select 'Drug exposure' as Category, - ard1.min_value as min_value, - ard1.p10_value as p10_value, - ard1.p25_value as p25_value, - ard1.median_value as median_value, - ard1.p75_value as p75_value, - ard1.p90_value as p90_value, - ard1.max_value as max_value -from @results_database_schema.ACHILLES_results_dist ard1 -where ard1.analysis_id = 703 +SELECT + 'Drug exposure' AS "category", + ard1.min_Value AS "min_Value", + ard1.p10_Value AS "p10_Value", + ard1.p25_Value AS "p25_Value", + ard1.median_Value AS "median_Value", + ard1.p75_Value AS "p75_Value", + ard1.p90_Value AS "p90_Value", + ard1.max_Value AS "max_Value" +FROM @results_database_schema.ACHILLES_results_dist ard1 +WHERE ard1.analysis_id = 703 -union +UNION -select 'Observation' as Category, - ard1.min_value as min_value, - ard1.p10_value as p10_value, - ard1.p25_value as p25_value, - ard1.median_value as median_value, - ard1.p75_value as p75_value, - ard1.p90_value as p90_value, - ard1.max_value as max_value -from @results_database_schema.ACHILLES_results_dist ard1 -where ard1.analysis_id = 803 +SELECT + 'Observation' AS "category", + ard1.min_Value AS "min_Value", + ard1.p10_Value AS "p10_Value", + ard1.p25_Value AS "p25_Value", + ard1.median_Value AS "median_Value", + ard1.p75_Value AS "p75_Value", + ard1.p90_Value AS "p90_Value", + ard1.max_Value AS "max_Value" +FROM @results_database_schema.ACHILLES_results_dist ard1 +WHERE ard1.analysis_id = 803 -union +UNION -select 'Drug era' as Category, - ard1.min_value as min_value, - ard1.p10_value as p10_value, - ard1.p25_value as p25_value, - ard1.median_value as median_value, - ard1.p75_value as p75_value, - ard1.p90_value as p90_value, - ard1.max_value as max_value -from @results_database_schema.ACHILLES_results_dist ard1 -where ard1.analysis_id = 903 +SELECT + 'Drug era' AS "category", + ard1.min_Value AS "min_Value", + ard1.p10_Value AS "p10_Value", + ard1.p25_Value AS "p25_Value", + ard1.median_Value AS "median_Value", + ard1.p75_Value AS "p75_Value", + ard1.p90_Value AS "p90_Value", + ard1.max_Value AS "max_Value" +FROM @results_database_schema.ACHILLES_results_dist ard1 +WHERE ard1.analysis_id = 903 -union +UNION -select 'Condition era' as Category, - ard1.min_value as min_value, - ard1.p10_value as p10_value, - ard1.p25_value as p25_value, - ard1.median_value as median_value, - ard1.p75_value as p75_value, - ard1.p90_value as p90_value, - ard1.max_value as max_value -from @results_database_schema.ACHILLES_results_dist ard1 -where ard1.analysis_id = 1003 +SELECT + 'Condition era' AS "category", + ard1.min_Value AS "min_Value", + ard1.p10_Value AS "p10_Value", + ard1.p25_Value AS "p25_Value", + ard1.median_Value AS "median_Value", + ard1.p75_Value AS "p75_Value", + ard1.p90_Value AS "p90_Value", + ard1.max_Value AS "max_Value" +FROM @results_database_schema.ACHILLES_results_dist ard1 +WHERE ard1.analysis_id = 1003 diff --git a/src/main/resources/resources/cdmresults/sql/report/datadensity/recordsperperson.sql b/src/main/resources/resources/cdmresults/sql/report/datadensity/recordsperperson.sql index 7e6a1787de..3be98196a8 100644 --- a/src/main/resources/resources/cdmresults/sql/report/datadensity/recordsperperson.sql +++ b/src/main/resources/resources/cdmresults/sql/report/datadensity/recordsperperson.sql @@ -1,27 +1,64 @@ -select t1.table_name as SERIES_NAME, - t1.stratum_1 as X_CALENDAR_MONTH, - round(1.0*t1.count_value/denom.count_value,5) as Y_RECORD_COUNT -from -( - select 'Visit occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 220 - union all - select 'Condition occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 420 - union all - select 'Death' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 502 - union all - select 'Procedure occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 620 - union all - select 'Drug exposure' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 720 - union all - select 'Observation' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 820 - union all - select 'Drug era' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 920 - union all - select 'Condition era' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 1020 - union all - select 'Observation period' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 111 +SELECT + t1.table_name AS "series_Name", + t1.stratum_1 AS "x_Calendar_Month", + round(1.0 * t1.count_value / denom.count_value, 5) AS "y_Record_Count" +FROM + ( + SELECT + 'Visit occurrence' AS table_name, + stratum_1, + count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 220 + UNION ALL +SELECT + 'Condition occurrence' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 420 +UNION ALL +SELECT + 'Death' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 502 +UNION ALL +SELECT + 'Procedure occurrence' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 620 +UNION ALL +SELECT + 'Drug exposure' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 720 +UNION ALL +SELECT + 'Observation' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 820 +UNION ALL +SELECT + 'Drug era' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 920 +UNION ALL +SELECT + 'Condition era' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1020 +UNION ALL +SELECT + 'Observation period' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 111 ) t1 -inner join -(select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom -on t1.stratum_1 = denom.stratum_1 -ORDER BY SERIES_NAME, CAST(t1.stratum_1 as INT) +INNER JOIN +( SELECT * FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 117) denom +ON t1.stratum_1 = denom.stratum_1 +ORDER BY SERIES_NAME, CAST(t1.stratum_1 AS INT ) diff --git a/src/main/resources/resources/cdmresults/sql/report/datadensity/totalrecords.sql b/src/main/resources/resources/cdmresults/sql/report/datadensity/totalrecords.sql index 78d7508f17..721d3ec19a 100644 --- a/src/main/resources/resources/cdmresults/sql/report/datadensity/totalrecords.sql +++ b/src/main/resources/resources/cdmresults/sql/report/datadensity/totalrecords.sql @@ -1,24 +1,61 @@ -select table_name as SERIES_NAME, - stratum_1 as X_CALENDAR_MONTH, - count_value as Y_RECORD_COUNT -from -( - select 'Visit occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 220 - union all - select 'Condition occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 420 - union all - select 'Death' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 502 - union all - select 'Procedure occurrence' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 620 - union all - select 'Drug exposure' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 720 - union all - select 'Observation' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 820 - union all - select 'Drug era' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 920 - union all - select 'Condition era' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 1020 - union all - select 'Observation period' as table_name, stratum_1, count_value from @results_database_schema.ACHILLES_results where analysis_id = 111 +SELECT + table_name AS "series_Name", + stratum_1 AS "x_Calendar_Month", + count_value AS "y_Record_Count" +FROM + ( + SELECT + 'Visit occurrence' AS table_name, + stratum_1, + count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 220 + UNION ALL +SELECT + 'Condition occurrence' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 420 +UNION ALL +SELECT + 'Death' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 502 +UNION ALL +SELECT + 'Procedure occurrence' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 620 +UNION ALL +SELECT + 'Drug exposure' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 720 +UNION ALL +SELECT + 'Observation' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 820 +UNION ALL +SELECT + 'Drug era' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 920 +UNION ALL +SELECT + 'Condition era' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1020 +UNION ALL +SELECT + 'Observation period' AS table_name, + stratum_1, + count_value +FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 111 ) t1 -ORDER BY SERIES_NAME, CAST(stratum_1 as INT) \ No newline at end of file +ORDER BY SERIES_NAME, CAST(stratum_1 AS INT ) \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/death/sqlAgeAtDeath.sql b/src/main/resources/resources/cdmresults/sql/report/death/sqlAgeAtDeath.sql index 9c61cbf843..ba2bc655c3 100644 --- a/src/main/resources/resources/cdmresults/sql/report/death/sqlAgeAtDeath.sql +++ b/src/main/resources/resources/cdmresults/sql/report/death/sqlAgeAtDeath.sql @@ -1,12 +1,13 @@ -select c2.concept_name as category, - ard1.min_value as min_value, - ard1.p10_value as P10_value, - ard1.p25_value as P25_value, - ard1.median_value as median_value, - ard1.p75_value as P75_value, - ard1.p90_value as P90_value, - ard1.max_value as max_value -from @results_database_schema.ACHILLES_results_dist ard1 - inner join - @vocab_database_schema.concept c2 on ard1.stratum_1 = CAST(c2.concept_id as VARCHAR) -where ard1.analysis_id = 506 \ No newline at end of file +SELECT + c2.concept_name AS "category", + ard1.min_value AS "min_Value", + ard1.p10_value AS "p10_Value", + ard1.p25_value AS "p25_Value", + ard1.median_value AS "median_Value", + ard1.p75_value AS "p75_Value", + ard1.p90_value AS "p90_Value", + ard1.max_value AS "max_Value" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN +@vocab_database_schema.concept c2 ON ard1.stratum_1 = CAST(c2.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 506 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/death/sqlDeathByType.sql b/src/main/resources/resources/cdmresults/sql/report/death/sqlDeathByType.sql index 570560aaa3..f41619be70 100644 --- a/src/main/resources/resources/cdmresults/sql/report/death/sqlDeathByType.sql +++ b/src/main/resources/resources/cdmresults/sql/report/death/sqlDeathByType.sql @@ -1,6 +1,7 @@ -select c2.concept_id as concept_id, - c2.concept_name as concept_name, - ar1.count_value as count_value -from @results_database_schema.ACHILLES_results ar1 - inner join @vocab_database_schema.concept c2 on ar1.stratum_1 = CAST(c2.concept_id as VARCHAR) -where ar1.analysis_id = 505 \ No newline at end of file +SELECT + c2.concept_id AS "conceptId", + c2.concept_name AS "conceptName", + ar1.count_value AS "countValue" +FROM @results_database_schema.ACHILLES_results ar1 +INNER JOIN @vocab_database_schema.concept c2 ON ar1.stratum_1 = CAST(c2.concept_id AS VARCHAR ) +WHERE ar1.analysis_id = 505 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByGenderAgeYear.sql index 7127c7937f..c679f673fe 100644 --- a/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByGenderAgeYear.sql +++ b/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByGenderAgeYear.sql @@ -1,13 +1,22 @@ -select cast(cast(num.stratum_3 as int)*10 as varchar) + '-' + cast((cast(num.stratum_3 as int)+1)*10-1 as varchar) as trellis_name, --age decile - c2.concept_name as series_name, --gender - num.stratum_1 as x_calendar_year, -- calendar year, note, there could be blanks - ROUND(1000*(1.0*num.count_value/denom.count_value),5) as y_prevalence_1000pp --prevalence, per 1000 persons -from - (select * from @results_database_schema.ACHILLES_results where analysis_id = 504) num - inner join - (select * from @results_database_schema.ACHILLES_results where analysis_id = 116) denom on num.stratum_1 = denom.stratum_1 --calendar year - and num.stratum_2 = denom.stratum_2 --gender - and num.stratum_3 = denom.stratum_3 --age decile - inner join @vocab_database_schema.concept c2 on num.stratum_2 = CAST(c2.concept_id as VARCHAR) -where c2.concept_id in (8507, 8532) +SELECT + cast(cast(num.stratum_3 AS INT) * 10 AS VARCHAR) + '-' + + cast((cast(num.stratum_3 AS INT) + 1) * 10 - 1 AS VARCHAR) AS "trellis_Name", + --age decile + c2.concept_name AS "series_Name", + --gender + num.stratum_1 AS "x_Calendar_Year", + -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num.count_value / denom.count_value), 5) AS "y_Prevalence_1000Pp" --prevalence, per 1000 persons +FROM + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 504) num + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 116) denom + ON num.stratum_1 = denom.stratum_1 --calendar year + AND num.stratum_2 = denom.stratum_2 --gender + AND num.stratum_3 = denom.stratum_3 + --age decile + INNER JOIN @vocab_database_schema.concept c2 ON num.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE c2.concept_id IN (8507, 8532) diff --git a/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByMonth.sql index 39235d7ab1..4d0fc19f7a 100644 --- a/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByMonth.sql +++ b/src/main/resources/resources/cdmresults/sql/report/death/sqlPrevalenceByMonth.sql @@ -1,7 +1,12 @@ -select num.stratum_1 as x_calendar_month, -- calendar year, note, there could be blanks - 1000*(1.0*num.count_value/denom.count_value) as y_prevalence_1000pp --prevalence, per 1000 persons -from - (select * from @results_database_schema.ACHILLES_results where analysis_id = 502) num - inner join - (select * from @results_database_schema.ACHILLES_results where analysis_id = 117) denom on num.stratum_1 = denom.stratum_1 --calendar year +SELECT + num.stratum_1 AS "x_Calendar_Month", + -- calendar year, note, there could be blanks + 1000 * (1.0 * num.count_value / denom.count_value) AS "y_Prevalence_1000Pp" --prevalence, per 1000 persons +FROM + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 502) num + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 117) denom + ON num.stratum_1 = denom.stratum_1 --calendar year diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/ageAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/ageAtFirstOccurrence.sql new file mode 100644 index 0000000000..a412c37119 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/ageAtFirstOccurrence.sql @@ -0,0 +1,20 @@ +SELECT + c1.concept_id AS "conceptId", + c2.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN +@vocab_database_schema.concept c2 +ON ard1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 706 +AND ard1.count_value > 0 +AND c1.concept_id = @conceptId \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/byType.sql b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/byType.sql new file mode 100644 index 0000000000..e4a4479456 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/byType.sql @@ -0,0 +1,14 @@ +SELECT + c1.concept_id AS "drugConceptId", + c2.concept_id AS "conceptId", + c2.concept_name AS "conceptName", + ar1.count_value AS "countValue" +FROM @results_database_schema.ACHILLES_results ar1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN +@vocab_database_schema.concept c2 +ON ar1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ar1.analysis_id = 705 +AND CAST(ar1.stratum_1 AS INT) = @conceptId \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/daysSupplyDistribution.sql b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/daysSupplyDistribution.sql new file mode 100644 index 0000000000..ea5524b228 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/daysSupplyDistribution.sql @@ -0,0 +1,16 @@ +SELECT + c1.concept_id AS "drugConceptId", + 'Days supply' AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 715 +AND ard1.count_value > 0 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/prevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/prevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..8c451365e2 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/prevalenceByGenderAgeYear.sql @@ -0,0 +1,41 @@ +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptName", + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS + VARCHAR) AS "trellisName", + --age decile + c2.concept_name AS "seriesName", + --gender + CAST(num_stratum_2 AS INT) AS "xCalendarYear", + -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), + 5) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM ( + SELECT + num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 704 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp + INNER JOIN @vocab_database_schema.concept c1 +ON num_stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 +ON num_stratum_3 = CAST(c2.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/prevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/prevalenceByMonth.sql new file mode 100644 index 0000000000..61023605cf --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/prevalenceByMonth.sql @@ -0,0 +1,17 @@ +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptName", + num.stratum_2 AS "xCalendarMonth", + round(1000 * (1.0 * num.count_value / denom.count_value), 5) AS "yPrevalence1000Pp" +FROM + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 702) num + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 117) denom + ON num.stratum_2 = denom.stratum_1 + --calendar year + INNER JOIN + @vocab_database_schema.concept c1 +ON num.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/quantityDistribution.sql b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/quantityDistribution.sql new file mode 100644 index 0000000000..aedf8e10b8 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/quantityDistribution.sql @@ -0,0 +1,16 @@ +SELECT + c1.concept_id AS "drugConceptId", + 'Quantity' AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 717 +AND ard1.count_value > 0 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/refillsDistribution.sql b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/refillsDistribution.sql new file mode 100644 index 0000000000..7dcd9ee0d4 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/drilldown/refillsDistribution.sql @@ -0,0 +1,16 @@ +SELECT + c1.concept_id AS "drugConceptId", + 'Refills' AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 716 +AND ard1.count_value > 0 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drug/treemap.sql b/src/main/resources/resources/cdmresults/sql/report/drug/treemap.sql new file mode 100644 index 0000000000..03bd197638 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drug/treemap.sql @@ -0,0 +1,112 @@ +SELECT + concept_hierarchy.concept_id AS "conceptId", + isnull(concept_hierarchy.atc1_concept_name, 'NA') + '||' + + isnull(concept_hierarchy.atc3_concept_name, 'NA') + '||' + + isnull(concept_hierarchy.atc5_concept_name, 'NA') + '||' + + isnull(concept_hierarchy.rxnorm_ingredient_concept_name, 'NA') + '||' + + concept_hierarchy.rxnorm_concept_name AS "conceptPath", + ar1.count_value AS "numPersons", + round(1.0 * ar1.count_value / denom.count_value, 5) AS "percentPersons", + round(1.0 * ar2.count_value / ar1.count_value, 5) AS "recordsPerPerson" +FROM (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 700) ar1 + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 701) ar2 + ON ar1.stratum_1 = ar2.stratum_1 + INNER JOIN + ( + SELECT + rxnorm.concept_id, + rxnorm.concept_name AS rxnorm_concept_name, + rxnorm.rxnorm_ingredient_concept_name, + atc5_to_atc3.atc5_concept_name, + atc3_to_atc1.atc3_concept_name, + atc1.concept_name AS atc1_concept_name + FROM + ( + SELECT + c1.concept_id, + c1.concept_name, + c2.concept_id AS rxnorm_ingredient_concept_id, + c2.concept_name AS RxNorm_ingredient_concept_name + FROM @vocab_database_schema.concept c1 + INNER JOIN @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.domain_id = 'Drug' + INNER JOIN @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.domain_id = 'Drug' + AND c2.concept_class_id = 'Ingredient' + ) rxnorm + LEFT JOIN + (SELECT + c1.concept_id AS rxnorm_ingredient_concept_id, + max(c2.concept_id) AS atc5_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.domain_id = 'Drug' + AND c1.concept_class_id = 'Ingredient' + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'ATC' + AND c2.concept_class_id = 'ATC 4th' + GROUP BY c1.concept_id + ) rxnorm_to_atc5 + ON rxnorm.rxnorm_ingredient_concept_id = rxnorm_to_atc5.rxnorm_ingredient_concept_id + + LEFT JOIN + (SELECT + c1.concept_id AS atc5_concept_id, + c1.concept_name AS atc5_concept_name, + max(c2.concept_id) AS atc3_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'ATC' + AND c1.concept_class_id = 'ATC 4th' + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'ATC' + AND c2.concept_class_id = 'ATC 2nd' + GROUP BY c1.concept_id, c1.concept_name + ) atc5_to_atc3 + ON rxnorm_to_atc5.atc5_concept_id = atc5_to_atc3.atc5_concept_id + + LEFT JOIN + (SELECT + c1.concept_id AS atc3_concept_id, + c1.concept_name AS atc3_concept_name, + max(c2.concept_id) AS atc1_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'ATC' + AND c1.concept_class_id = 'ATC 2nd' + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'ATC' + AND c2.concept_class_id = 'ATC 1st' + GROUP BY c1.concept_id, c1.concept_name + ) atc3_to_atc1 + ON atc5_to_atc3.atc3_concept_id = atc3_to_atc1.atc3_concept_id + + LEFT JOIN @vocab_database_schema.concept atc1 + ON atc3_to_atc1.atc1_concept_id = atc1.concept_id + ) concept_hierarchy + ON ar1.stratum_1 = CAST(concept_hierarchy.concept_id AS VARCHAR) + , + (SELECT count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1) denom + +ORDER BY ar1.count_value DESC \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/ageAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/ageAtFirstOccurrence.sql new file mode 100644 index 0000000000..882e873fec --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/ageAtFirstOccurrence.sql @@ -0,0 +1,19 @@ +SELECT + c1.concept_id AS "conceptId", + c2.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN +@vocab_database_schema.concept c2 +ON ard1.stratum_2 = cast(c2.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 906 +AND ard1.count_value > 0 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/lengthOfEra.sql b/src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/lengthOfEra.sql new file mode 100644 index 0000000000..f32c7d3a48 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/lengthOfEra.sql @@ -0,0 +1,16 @@ +SELECT + c1.concept_id AS "conceptId", + 'Length of Era' AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 907 +AND ard1.count_value > 0 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/prevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/prevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..5ec29e368d --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/prevalenceByGenderAgeYear.sql @@ -0,0 +1,41 @@ +SELECT + c1.concept_id AS "conceptId", + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS + VARCHAR) AS "trellisName", + --age decile + c2.concept_name AS "seriesName", + --gender + CAST(num_stratum_2 AS INT) AS "xCalendarYear", + -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), + 5) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM ( + SELECT + num.stratum_1 AS "num_stratum_1", + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 904 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp + INNER JOIN @vocab_database_schema.concept c1 +ON num_stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 +ON num_stratum_3 = CAST(c2.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId + diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/prevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/prevalenceByMonth.sql new file mode 100644 index 0000000000..12fe5ab8e3 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drugera/drilldown/prevalenceByMonth.sql @@ -0,0 +1,15 @@ +SELECT + c1.concept_id AS "conceptId", + num.stratum_2 AS "xCalendarMonth", + round(1000 * (1.0 * num.count_value / denom.count_value), 5) AS "yPrevalence1000Pp" +FROM + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 902) num + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 117) denom + ON num.stratum_2 = denom.stratum_1 + INNER JOIN + @vocab_database_schema.concept c1 +ON num.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId diff --git a/src/main/resources/resources/cdmresults/sql/report/drugera/treemap.sql b/src/main/resources/resources/cdmresults/sql/report/drugera/treemap.sql new file mode 100644 index 0000000000..5f09c64226 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/drugera/treemap.sql @@ -0,0 +1,105 @@ +SELECT + concept_hierarchy.rxnorm_ingredient_concept_id AS "conceptId", + isnull(concept_hierarchy.atc1_concept_name, 'NA') + '||' + + isnull(concept_hierarchy.atc3_concept_name, 'NA') + '||' + + isnull(concept_hierarchy.atc5_concept_name, 'NA') + '||' + + isnull(concept_hierarchy.rxnorm_ingredient_concept_name, '||') AS "conceptPath", + ar1.count_value AS "numPersons", + 1.0 * ar1.count_value / denom.count_value AS "percentPersons", + ar2.avg_value AS "lengthOfEra" +FROM (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 900) ar1 + INNER JOIN + (SELECT + stratum_1, + avg_value + FROM @results_database_schema.ACHILLES_results_dist WHERE analysis_id = 907) ar2 + ON ar1.stratum_1 = ar2.stratum_1 + INNER JOIN + ( + SELECT + rxnorm.rxnorm_ingredient_concept_id, + rxnorm.rxnorm_ingredient_concept_name, + atc5_to_atc3.atc5_concept_name, + atc3_to_atc1.atc3_concept_name, + atc1.concept_name AS atc1_concept_name + FROM + ( + SELECT + c2.concept_id AS rxnorm_ingredient_concept_id, + c2.concept_name AS RxNorm_ingredient_concept_name + FROM + @vocab_database_schema.concept c2 + WHERE + c2.domain_id = 'Drug' + AND c2.concept_class_id = 'Ingredient' + ) rxnorm + LEFT JOIN + (SELECT + c1.concept_id AS rxnorm_ingredient_concept_id, + max(c2.concept_id) AS atc5_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.domain_id = 'Drug' + AND c1.concept_class_id = 'Ingredient' + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'ATC' + AND c2.concept_class_id = 'ATC 4th' + GROUP BY c1.concept_id + ) rxnorm_to_atc5 + ON rxnorm.rxnorm_ingredient_concept_id = rxnorm_to_atc5.rxnorm_ingredient_concept_id + + LEFT JOIN + (SELECT + c1.concept_id AS atc5_concept_id, + c1.concept_name AS atc5_concept_name, + max(c2.concept_id) AS atc3_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'ATC' + AND c1.concept_class_id = 'ATC 4th' + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'ATC' + AND c2.concept_class_id = 'ATC 2nd' + GROUP BY c1.concept_id, c1.concept_name + ) atc5_to_atc3 + ON rxnorm_to_atc5.atc5_concept_id = atc5_to_atc3.atc5_concept_id + + LEFT JOIN + (SELECT + c1.concept_id AS atc3_concept_id, + c1.concept_name AS atc3_concept_name, + max(c2.concept_id) AS atc1_concept_id + FROM + @vocab_database_schema.concept c1 + INNER JOIN + @vocab_database_schema.concept_ancestor ca1 + ON c1.concept_id = ca1.descendant_concept_id + AND c1.vocabulary_id = 'ATC' + AND c1.concept_class_id = 'ATC 2nd' + INNER JOIN + @vocab_database_schema.concept c2 + ON ca1.ancestor_concept_id = c2.concept_id + AND c2.vocabulary_id = 'ATC' + AND c2.concept_class_id = 'ATC 1st' + GROUP BY c1.concept_id, c1.concept_name + ) atc3_to_atc1 + ON atc5_to_atc3.atc3_concept_id = atc3_to_atc1.atc3_concept_id + + LEFT JOIN @vocab_database_schema.concept atc1 + ON atc3_to_atc1.atc1_concept_id = atc1.concept_id + ) concept_hierarchy + ON ar1.stratum_1 = CAST(concept_hierarchy.rxnorm_ingredient_concept_id AS VARCHAR) + , + (SELECT count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1) denom diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/ageAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/ageAtFirstOccurrence.sql new file mode 100644 index 0000000000..413b6856d7 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/ageAtFirstOccurrence.sql @@ -0,0 +1,15 @@ +SELECT + c1.concept_id AS "conceptId", + c2.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN @vocab_database_schema.concept c1 ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 ON ard1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 1806 +AND c1.concept_id = @conceptId diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/byType.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/byType.sql new file mode 100644 index 0000000000..6348563ef7 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/byType.sql @@ -0,0 +1,11 @@ +SELECT + c1.concept_id AS "measurementConceptId", + c1.concept_name AS "measurementConceptName", + c2.concept_id AS "conceptId", + c2.concept_name AS "conceptName", + ar1.count_value AS "countValue" +FROM @results_database_schema.ACHILLES_results ar1 +INNER JOIN @vocab_database_schema.concept c1 ON ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 ON ar1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ar1.analysis_id = 1805 +AND CAST(ar1.stratum_1 AS INT) = @conceptId \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/lowerLimitDistribution.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/lowerLimitDistribution.sql new file mode 100644 index 0000000000..786ebc20d1 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/lowerLimitDistribution.sql @@ -0,0 +1,15 @@ +SELECT + c1.concept_id AS "conceptId", + c2.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN @vocab_database_schema.concept c1 ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 ON ard1.stratum_2 = cast(c2.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 1816 +AND ard1.count_value > 0 diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/measurementValueDistribution.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/measurementValueDistribution.sql new file mode 100644 index 0000000000..21bab0d0e3 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/measurementValueDistribution.sql @@ -0,0 +1,16 @@ +SELECT + c1.concept_id AS "conceptId", + c2.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN @vocab_database_schema.concept c1 ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 ON ard1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 1815 +AND ard1.count_value > 0 + diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/prevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/prevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..6a6fb70c25 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/prevalenceByGenderAgeYear.sql @@ -0,0 +1,42 @@ +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptName", + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS + VARCHAR) AS "trellisName", + --age decile + c2.concept_name AS "seriesName", + --gender + CAST(num_stratum_2 AS INT) AS "xCalendarYear", + -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), + 5) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM ( + SELECT + num.stratum_1 AS "num_stratum_1", + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 1804 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp + INNER JOIN @vocab_database_schema.concept c1 +ON num_stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 +ON num_stratum_3 = CAST(c2.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId + diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/prevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/prevalenceByMonth.sql new file mode 100644 index 0000000000..ab13f19bdf --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/prevalenceByMonth.sql @@ -0,0 +1,17 @@ +SELECT + c1.concept_id AS "conceptId", + --all rows for all concepts, but you may split by conceptid + c1.concept_name AS "conceptName", + num.stratum_2 AS "xCalendarMonth", + -- calendar year, note, there could be blanks + round(1000 * (1.0 * num.count_value / denom.count_value), 5) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1802) num + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 117) denom ON num.stratum_2 = denom.stratum_1 + --calendar year + INNER JOIN @vocab_database_schema.concept c1 ON num.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId + diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/recordsByUnit.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/recordsByUnit.sql new file mode 100644 index 0000000000..1c0741e70d --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/recordsByUnit.sql @@ -0,0 +1,10 @@ +SELECT + c1.concept_id AS "measurementConceptId", + c1.concept_name AS "measurementConceptName", + c2.concept_id AS "conceptId", + c2.concept_name AS "conceptName", + ar1.count_value AS "countValue" +FROM @results_database_schema.ACHILLES_results ar1 +INNER JOIN @vocab_database_schema.concept c1 ON ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 ON ar1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ar1.analysis_id = 1807 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/upperLimitDistribution.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/upperLimitDistribution.sql new file mode 100644 index 0000000000..01a1abb212 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/upperLimitDistribution.sql @@ -0,0 +1,15 @@ +SELECT + c1.concept_id AS "conceptId", + c2.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN @vocab_database_schema.concept c1 ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 ON ard1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 1817 +AND ard1.count_value > 0 diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/valuesRelativeToNorm.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/valuesRelativeToNorm.sql new file mode 100644 index 0000000000..99d538d574 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/drilldown/valuesRelativeToNorm.sql @@ -0,0 +1,10 @@ +SELECT + c1.concept_id AS "measurementConceptId", + c1.concept_name AS "measurementConceptName", + c2.concept_id AS "conceptId", + c2.concept_name + ': ' + ar1.stratum_3 AS "conceptName", + ar1.count_value AS "countValue" +FROM @results_database_schema.ACHILLES_results ar1 +INNER JOIN @vocab_database_schema.concept c1 ON ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 ON ar1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ar1.analysis_id = 1818 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/measurement/treemap.sql b/src/main/resources/resources/cdmresults/sql/report/measurement/treemap.sql new file mode 100644 index 0000000000..f23da5bb64 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/measurement/treemap.sql @@ -0,0 +1,43 @@ +SELECT + concept_hierarchy.concept_id AS "conceptId", + isNull(concept_hierarchy.level3_concept_name, 'NA') + + '||' + isNull(concept_hierarchy.level2_concept_name, 'NA') + + '||' + isNull(concept_hierarchy.level1_concept_name, 'NA') + + '||' + isNull(concept_hierarchy.concept_name, 'NA') AS "conceptPath", + ar1.count_value AS "numPersons", + 1.0 * ar1.count_value / denom.count_value AS "percentPersons", + 1.0 * ar2.count_value / ar1.count_value AS "recordsPerPerson" +FROM (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1800) ar1 + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1801) ar2 + ON ar1.stratum_1 = ar2.stratum_1 + INNER JOIN + ( + SELECT + m.concept_id, + m.concept_name, + max(c1.concept_name) AS level1_concept_name, + max(c2.concept_name) AS level2_concept_name, + max(c3.concept_name) AS level3_concept_name + FROM + ( + SELECT DISTINCT + concept_id, + concept_name + FROM @vocab_database_schema.concept c + JOIN @cdm_database_schema.measurement M ON c.concept_id = M.measurement_concept_id + ) m LEFT JOIN + @vocab_database_schema.concept_ancestor ca1 ON M.concept_id = ca1.DESCENDANT_CONCEPT_ID AND ca1.min_levels_of_separation = 1 + LEFT JOIN @vocab_database_schema.concept c1 ON ca1.ANCESTOR_CONCEPT_ID = c1.concept_id + LEFT JOIN @vocab_database_schema.concept_ancestor ca2 ON c1.concept_id = ca2.DESCENDANT_CONCEPT_ID AND ca2.min_levels_of_separation = 1 + LEFT JOIN @vocab_database_schema.concept c2 ON ca2.ANCESTOR_CONCEPT_ID = c2.concept_id + LEFT JOIN @vocab_database_schema.concept_ancestor ca3 ON c2.concept_id = ca3.DESCENDANT_CONCEPT_ID AND ca3.min_levels_of_separation = 1 + LEFT JOIN @vocab_database_schema.concept c3 ON ca3.ANCESTOR_CONCEPT_ID = c3.concept_id + GROUP BY M.concept_id, M.concept_name + ) concept_hierarchy ON ar1.stratum_1 = CAST(concept_hierarchy.concept_id AS VARCHAR) + , + (SELECT count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1) denom +ORDER BY ar1.count_value DESC diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/drilldown/ageAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/report/observation/drilldown/ageAtFirstOccurrence.sql new file mode 100644 index 0000000000..13998303e3 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observation/drilldown/ageAtFirstOccurrence.sql @@ -0,0 +1,15 @@ +SELECT + c1.concept_id AS "conceptId", + c2.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN @vocab_database_schema.concept c1 ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 ON ard1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 806 +AND c1.concept_id = @conceptId diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/drilldown/byType.sql b/src/main/resources/resources/cdmresults/sql/report/observation/drilldown/byType.sql new file mode 100644 index 0000000000..b9a7944e1a --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observation/drilldown/byType.sql @@ -0,0 +1,11 @@ +SELECT + c1.concept_id AS "observationConceptId", + c1.concept_name AS "observationConceptName", + c2.concept_id AS "conceptId", + c2.concept_name AS "conceptName", + ar1.count_value AS "countValue" +FROM @results_database_schema.ACHILLES_results ar1 +INNER JOIN @vocab_database_schema.concept c1 ON ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 ON ar1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ar1.analysis_id = 805 +AND CAST(ar1.stratum_1 AS INT) = @conceptId \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/drilldown/prevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/observation/drilldown/prevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..056477535f --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observation/drilldown/prevalenceByGenderAgeYear.sql @@ -0,0 +1,42 @@ +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptName", + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS + VARCHAR) AS "trellisName", + --age decile + c2.concept_name AS "seriesName", + --gender + CAST(num_stratum_2 AS INT) AS "xCalendarYear", + -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), + 5) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM ( + SELECT + num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 804 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp + INNER JOIN @vocab_database_schema.concept c1 +ON num_stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 +ON num_stratum_3 = CAST(c2.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId + diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/drilldown/prevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/observation/drilldown/prevalenceByMonth.sql new file mode 100644 index 0000000000..29ef6c55f8 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observation/drilldown/prevalenceByMonth.sql @@ -0,0 +1,17 @@ +SELECT + c1.concept_id AS "conceptId", + --all rows for all concepts, but you may split by conceptid + c1.concept_name AS "conceptName", + num.stratum_2 AS "xCalendarMonth", + -- calendar year, note, there could be blanks + round(1000 * (1.0 * num.count_value / denom.count_value), 5) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 802) num + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 117) denom ON num.stratum_2 = denom.stratum_1 + --calendar year + INNER JOIN @vocab_database_schema.concept c1 ON num.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId + diff --git a/src/main/resources/resources/cdmresults/sql/report/observation/treemap.sql b/src/main/resources/resources/cdmresults/sql/report/observation/treemap.sql new file mode 100644 index 0000000000..b41ead228e --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/observation/treemap.sql @@ -0,0 +1,43 @@ +SELECT + concept_hierarchy.concept_id AS "conceptId", + isNull(concept_hierarchy.level3_concept_name, 'NA') + + '||' + isNull(concept_hierarchy.level2_concept_name, 'NA') + + '||' + isNull(concept_hierarchy.level1_concept_name, 'NA') + + '||' + isNull(concept_hierarchy.concept_name, 'NA') AS "conceptPath", + ar1.count_value AS "numPersons", + 1.0 * ar1.count_value / denom.count_value AS "percentPersons", + 1.0 * ar2.count_value / ar1.count_value AS "recordsPerPerson" +FROM (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 800) ar1 + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 801) ar2 + ON ar1.stratum_1 = ar2.stratum_1 + INNER JOIN + ( + SELECT + obs.concept_id, + obs.concept_name, + max(c1.concept_name) AS level1_concept_name, + max(c2.concept_name) AS level2_concept_name, + max(c3.concept_name) AS level3_concept_name + FROM + ( + SELECT + concept_id, + concept_name + FROM @vocab_database_schema.concept + WHERE domain_id = 'Observation' + ) obs LEFT JOIN + @vocab_database_schema.concept_ancestor ca1 ON obs.concept_id = ca1.DESCENDANT_CONCEPT_ID AND ca1.min_levels_of_separation = 1 + LEFT JOIN @vocab_database_schema.concept c1 ON ca1.ANCESTOR_CONCEPT_ID = c1.concept_id + LEFT JOIN @vocab_database_schema.concept_ancestor ca2 ON c1.concept_id = ca2.DESCENDANT_CONCEPT_ID AND ca2.min_levels_of_separation = 1 + LEFT JOIN @vocab_database_schema.concept c2 ON ca2.ANCESTOR_CONCEPT_ID = c2.concept_id + LEFT JOIN @vocab_database_schema.concept_ancestor ca3 ON c2.concept_id = ca3.DESCENDANT_CONCEPT_ID AND ca3.min_levels_of_separation = 1 + LEFT JOIN @vocab_database_schema.concept c3 ON ca3.ANCESTOR_CONCEPT_ID = c3.concept_id + GROUP BY obs.concept_id, obs.concept_name + ) concept_hierarchy ON ar1.stratum_1 = CAST(concept_hierarchy.concept_id AS VARCHAR) + , + (SELECT count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1) denom +ORDER BY ar1.count_value DESC diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/ageatfirst.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/ageatfirst.sql index 00956a3c6e..3ad1944b55 100644 --- a/src/main/resources/resources/cdmresults/sql/report/observationperiod/ageatfirst.sql +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/ageatfirst.sql @@ -1,10 +1,13 @@ -select cast(ar1.stratum_1 as int) as interval_index, - ar1.count_value as count_value, - round(1.0*ar1.count_value / denom.count_value,5) as percent_value -from -( - select * from @results_database_schema.ACHILLES_results where analysis_id = 101 -) ar1, -( - select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 -) denom \ No newline at end of file +SELECT + cast(ar1.stratum_1 AS INT) AS "intervalIndex", + ar1.count_value AS "countValue", + round(1.0 * ar1.count_value / denom.count_value, 5) AS "percentValue" +FROM + ( + SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 101 + ) ar1, + ( + SELECT count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1 + ) denom \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/agebygender.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/agebygender.sql index 66992b463d..7d29677228 100644 --- a/src/main/resources/resources/cdmresults/sql/report/observationperiod/agebygender.sql +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/agebygender.sql @@ -1,11 +1,12 @@ -select c1.concept_name as Category, - ard1.min_value as min_value, - ard1.p10_value as p10_value, - ard1.p25_value as p25_value, - ard1.median_value as median_value, - ard1.p75_value as p75_value, - ard1.p90_value as p90_value, - ard1.max_value as max_value -from @results_database_schema.ACHILLES_results_dist ard1 -inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) -where ard1.analysis_id = 104 \ No newline at end of file +SELECT + c1.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN @vocab_database_schema.concept c1 ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 104 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/cumulativeduration.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/cumulativeduration.sql index 7542e49c47..ca937f067e 100644 --- a/src/main/resources/resources/cdmresults/sql/report/observationperiod/cumulativeduration.sql +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/cumulativeduration.sql @@ -1,13 +1,18 @@ -select 'Length of observation' as series_name, - cast(ar1.stratum_1 as int)*30 as x_length_of_observation, - round(1.0*sum(ar2.count_value) / denom.count_value,5) as y_percent_persons -from (select * from @results_database_schema.ACHILLES_results where analysis_id = 108) ar1 -inner join -( - select * from @results_database_schema.ACHILLES_results where analysis_id = 108 -) ar2 on ar1.analysis_id = ar2.analysis_id and cast(ar1.stratum_1 as int) <= cast(ar2.stratum_1 as int), -( - select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 -) denom -group by cast(ar1.stratum_1 as int)*30, denom.count_value -order by cast(ar1.stratum_1 as int)*30 asc +SELECT + 'Length of observation' AS "seriesName", + cast(ar1.stratum_1 AS INT) * 30 AS "xLengthOfObservation", + round(1.0 * sum(ar2.count_value) / denom.count_value, 5) AS "yPercentPersons" +FROM (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 108) ar1 + INNER JOIN + ( + SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 108 + ) ar2 ON ar1.analysis_id = ar2.analysis_id AND cast(ar1.stratum_1 AS INT) <= cast(ar2.stratum_1 AS INT) + , + ( + SELECT count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1 + ) denom +GROUP BY cast(ar1.stratum_1 AS INT) * 30, denom.count_value +ORDER BY cast(ar1.stratum_1 AS INT) * 30 ASC diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_data.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_data.sql index ca38aba3a3..e31865129f 100644 --- a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_data.sql +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_data.sql @@ -1,9 +1,10 @@ -select cast(ar1.stratum_1 as int) as interval_index, - ar1.count_value as count_value, - round(1.0*ar1.count_value / denom.count_value,5) as percent_value -from @results_database_schema.ACHILLES_analysis aa1 -inner join @results_database_schema.ACHILLES_results ar1 on aa1.analysis_id = ar1.analysis_id, +SELECT + cast(ar1.stratum_1 AS INT) AS "intervalIndex", + ar1.count_value AS "countValue", + round(1.0 * ar1.count_value / denom.count_value, 5) AS "percentValue" +FROM @results_database_schema.ACHILLES_analysis aa1 +INNER JOIN @results_database_schema.ACHILLES_results ar1 ON aa1.analysis_id = ar1.analysis_id, ( - select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +SELECT count_value FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1 ) denom -where aa1.analysis_id = 108 +WHERE aa1.analysis_id = 108 diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_stats.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_stats.sql index 52f311c927..60c1dbf0cd 100644 --- a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_stats.sql +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlength_stats.sql @@ -1,9 +1,10 @@ -select min(cast(ar1.stratum_1 as int)) * 30 as min_value, - max(cast(ar1.stratum_1 as int)) * 30 as max_value, - 30 as interval_size -from @results_database_schema.ACHILLES_analysis aa1 -inner join @results_database_schema.ACHILLES_results ar1 on aa1.analysis_id = ar1.analysis_id, +SELECT + min(cast(ar1.stratum_1 AS INT)) * 30 AS "minValue", + max(cast(ar1.stratum_1 AS INT)) * 30 AS "maxValue", + 30 AS "intervalSize" +FROM @results_database_schema.ACHILLES_analysis aa1 +INNER JOIN @results_database_schema.ACHILLES_results ar1 ON aa1.analysis_id = ar1.analysis_id, ( - select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 +SELECT count_value FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1 ) denom -where aa1.analysis_id = 108 \ No newline at end of file +WHERE aa1.analysis_id = 108 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbyage.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbyage.sql index f69160bcae..b5ebf29f2c 100644 --- a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbyage.sql +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbyage.sql @@ -1,10 +1,12 @@ - select cast(cast(ard1.stratum_1 as int)*10 as varchar) + '-' + cast((cast(ard1.stratum_1 as int)+1)*10-1 as varchar) as category, - ard1.min_value as min_value, - ard1.p10_value as p10_value, - ard1.p25_value as p25_value, - ard1.median_value as median_value, - ard1.p75_value as p75_value, - ard1.p90_value as p90_value, - ard1.max_value as max_value -from @results_database_schema.ACHILLES_results_dist ard1 -where ard1.analysis_id = 107 +SELECT + cast(cast(ard1.stratum_1 AS INT) * 10 AS VARCHAR) + '-' + + cast((cast(ard1.stratum_1 AS INT) + 1) * 10 - 1 AS VARCHAR) AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +WHERE ard1.analysis_id = 107 diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbygender.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbygender.sql index 1383c2bb88..ad8b1a9f27 100644 --- a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbygender.sql +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observationlengthbygender.sql @@ -1,11 +1,12 @@ -select c1.concept_name as category, - ard1.min_value as min_value, - ard1.p10_value as p10_value, - ard1.p25_value as p25_value, - ard1.median_value as median_value, - ard1.p75_value as p75_value, - ard1.p90_value as p90_value, - ard1.max_value as max_value -from @results_database_schema.ACHILLES_results_dist ard1 -inner join @vocab_database_schema.concept c1 on ard1.stratum_1 = CAST(c1.concept_id as VARCHAR) -where ard1.analysis_id = 106 \ No newline at end of file +SELECT + c1.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN @vocab_database_schema.concept c1 ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 106 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbymonth.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbymonth.sql index f4143f1c7f..21ccf20d20 100644 --- a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbymonth.sql +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbymonth.sql @@ -1,7 +1,10 @@ -select cast(ar1.stratum_1 as int) as month_year, - ar1.count_value as count_value, - round(1.0*ar1.count_value / denom.count_value,5) as percent_value -from (select * from @results_database_schema.ACHILLES_results where analysis_id = 110) ar1, - (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom +SELECT + cast(ar1.stratum_1 AS INT) AS "monthYear", + ar1.count_value AS "countValue", + round(1.0 * ar1.count_value / denom.count_value, 5) AS "percentValue" +FROM (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 110) ar1, + (SELECT count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1) denom \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_data.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_data.sql index 084ac45880..305ad5b93e 100644 --- a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_data.sql +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_data.sql @@ -1,14 +1,17 @@ -select cast(ar1.stratum_1 as int) - MinValue.MinValue as interval_index, - ar1.count_value as count_value, - round(1.0*ar1.count_value / denom.count_value,5) as percent_value -from -( - select * from @results_database_schema.ACHILLES_results where analysis_id = 109 -) ar1, -( - select min(cast(stratum_1 as int)) as MinValue - from @results_database_schema.ACHILLES_results where analysis_id = 109 -) MinValue, -( - select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1 -) denom \ No newline at end of file +SELECT + cast(ar1.stratum_1 AS INT) - MinValue.MinValue AS "intervalIndex", + ar1.count_value AS "countValue", + round(1.0 * ar1.count_value / denom.count_value, 5) AS "percentValue" +FROM + ( + SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 109 + ) ar1, + ( + SELECT min(cast(stratum_1 AS INT)) AS MinValue + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 109 + ) MinValue, + ( + SELECT count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1 + ) denom \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_stats.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_stats.sql index 048971af81..a3b7af9a24 100644 --- a/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_stats.sql +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/observedbyyear_stats.sql @@ -1,5 +1,6 @@ -select min(cast(ar1.stratum_1 as int)) as min_value, - max(cast(ar1.stratum_1 as int)) as max_value, - 1 as interval_size -from @results_database_schema.ACHILLES_results ar1 -where ar1.analysis_id = 109 \ No newline at end of file +SELECT + min(cast(ar1.stratum_1 AS INT)) AS "minValue", + max(cast(ar1.stratum_1 AS INT)) AS "maxValue", + 1 AS "intervalSize" +FROM @results_database_schema.ACHILLES_results ar1 +WHERE ar1.analysis_id = 109 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/observationperiod/periodsperperson.sql b/src/main/resources/resources/cdmresults/sql/report/observationperiod/periodsperperson.sql index 67d048940d..ed8a22b208 100644 --- a/src/main/resources/resources/cdmresults/sql/report/observationperiod/periodsperperson.sql +++ b/src/main/resources/resources/cdmresults/sql/report/observationperiod/periodsperperson.sql @@ -1,5 +1,8 @@ -select row_number() over (order by ar1.stratum_1) as concept_id, - ar1.stratum_1 as concept_name, - ar1.count_value as count_value -from @results_database_schema.ACHILLES_results ar1 -where ar1.analysis_id = 113 \ No newline at end of file +SELECT + row_number() + OVER ( + ORDER BY ar1.stratum_1) AS "conceptId", + ar1.stratum_1 AS "conceptName", + ar1.count_value AS "countValue" +FROM @results_database_schema.ACHILLES_results ar1 +WHERE ar1.analysis_id = 113 \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/person/ethnicity.sql b/src/main/resources/resources/cdmresults/sql/report/person/ethnicity.sql index f6723341d0..f1f226f3d0 100644 --- a/src/main/resources/resources/cdmresults/sql/report/person/ethnicity.sql +++ b/src/main/resources/resources/cdmresults/sql/report/person/ethnicity.sql @@ -1,8 +1,9 @@ -select c1.concept_id as concept_id, - c1.concept_name as concept_name, - ar1.count_value as count_value -from @results_database_schema.ACHILLES_results ar1 - inner join - @vocab_database_schema.concept c1 - on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) -where ar1.analysis_id = 5 +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptName", + ar1.count_value AS "countValue" +FROM @results_database_schema.ACHILLES_results ar1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE ar1.analysis_id = 5 diff --git a/src/main/resources/resources/cdmresults/sql/report/person/gender.sql b/src/main/resources/resources/cdmresults/sql/report/person/gender.sql index f1587df99f..4257bf6140 100644 --- a/src/main/resources/resources/cdmresults/sql/report/person/gender.sql +++ b/src/main/resources/resources/cdmresults/sql/report/person/gender.sql @@ -1,9 +1,10 @@ -select c1.concept_id as concept_id, - c1.concept_name as concept_name, - ar1.count_value as count_value -from @results_database_schema.ACHILLES_results ar1 - inner join - @vocab_database_schema.concept c1 - on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) -where ar1.analysis_id = 2 -and c1.concept_id in (8507, 8532) \ No newline at end of file +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptName", + ar1.count_value AS "countValue" +FROM @results_database_schema.ACHILLES_results ar1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE ar1.analysis_id = 2 +AND c1.concept_id IN (8507, 8532) \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/person/population.sql b/src/main/resources/resources/cdmresults/sql/report/person/population.sql index 62824ad453..a1aaad032d 100644 --- a/src/main/resources/resources/cdmresults/sql/report/person/population.sql +++ b/src/main/resources/resources/cdmresults/sql/report/person/population.sql @@ -1,19 +1,21 @@ -(select aa1.analysis_name as attribute_name, - ar1.stratum_1 as attribute_value -from @results_database_schema.ACHILLES_analysis aa1 -inner join +(SELECT + aa1.analysis_name AS "attribute_name", + ar1.stratum_1 AS "attribute_value" + FROM @results_database_schema.ACHILLES_analysis aa1 +INNER JOIN @results_database_schema.ACHILLES_results ar1 -on aa1.analysis_id = ar1.analysis_id -where aa1.analysis_id = 0 +ON aa1.analysis_id = ar1.analysis_id + WHERE aa1.analysis_id = 0 -union + UNION -select aa1.analysis_name as attribute_name, -cast(ar1.count_value as varchar) as attribute_value -from @results_database_schema.ACHILLES_analysis aa1 -inner join +SELECT + aa1.analysis_name AS "attribute_name", + cast(ar1.count_value AS VARCHAR) AS "attribute_value" +FROM @results_database_schema.ACHILLES_analysis aa1 +INNER JOIN @results_database_schema.ACHILLES_results ar1 -on aa1.analysis_id = ar1.analysis_id -where aa1.analysis_id = 1 +ON aa1.analysis_id = ar1.analysis_id +WHERE aa1.analysis_id = 1 ) -order by attribute_name desc +ORDER BY attribute_name DESC diff --git a/src/main/resources/resources/cdmresults/sql/report/person/race.sql b/src/main/resources/resources/cdmresults/sql/report/person/race.sql index d4fb85c52e..b7d0df1371 100644 --- a/src/main/resources/resources/cdmresults/sql/report/person/race.sql +++ b/src/main/resources/resources/cdmresults/sql/report/person/race.sql @@ -1,8 +1,9 @@ -select c1.concept_id as concept_id, - c1.concept_name as concept_name, - ar1.count_value as count_value -from @results_database_schema.ACHILLES_results ar1 - inner join - @vocab_database_schema.concept c1 - on ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR) -where ar1.analysis_id = 4 +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptName", + ar1.count_value AS "countValue" +FROM @results_database_schema.ACHILLES_results ar1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE ar1.analysis_id = 4 diff --git a/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_data.sql b/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_data.sql index c70069eec4..e6ba0d7bae 100644 --- a/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_data.sql +++ b/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_data.sql @@ -1,7 +1,11 @@ -select cast(ar1.stratum_1 as int) - MinValue.MinValue as interval_index, - ar1.count_value as count_value, - round(1.0*ar1.count_value / denom.count_value,5) as percent_value -from (select * from @results_database_schema.ACHILLES_results where analysis_id = 3) ar1, - (select min(cast(stratum_1 as int)) as MinValue from @results_database_schema.ACHILLES_results where analysis_id = 3) MinValue, - (select count_value from @results_database_schema.ACHILLES_results where analysis_id = 1) denom -order by ar1.stratum_1 asc +SELECT + cast(ar1.stratum_1 AS INT) - MinValue.MinValue AS "intervalIndex", + ar1.count_value AS "countValue", + round(1.0 * ar1.count_value / denom.count_value, 5) AS "percentValue" +FROM (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 3) ar1, + (SELECT min(cast(stratum_1 AS INT)) AS MinValue + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 3) MinValue, + (SELECT count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1) denom +ORDER BY ar1.stratum_1 ASC diff --git a/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_stats.sql b/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_stats.sql index 63da3ee20d..e6166b36ef 100644 --- a/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_stats.sql +++ b/src/main/resources/resources/cdmresults/sql/report/person/yearofbirth_stats.sql @@ -1,5 +1,6 @@ -select min(cast(ar1.stratum_1 as int)) as min_value, - max(cast(ar1.stratum_1 as int)) as max_value, - 1 as interval_size -from @results_database_schema.ACHILLES_results ar1 -where ar1.analysis_id = 3 +SELECT + min(cast(ar1.stratum_1 AS INT)) AS "minValue", + max(cast(ar1.stratum_1 AS INT)) AS "maxValue", + 1 AS "intervalSize" +FROM @results_database_schema.ACHILLES_results ar1 +WHERE ar1.analysis_id = 3 diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/ageAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/ageAtFirstOccurrence.sql new file mode 100644 index 0000000000..367a7c25df --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/ageAtFirstOccurrence.sql @@ -0,0 +1,19 @@ +SELECT + c1.concept_id AS "conceptId", + c2.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN +@vocab_database_schema.concept c1 +ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN +@vocab_database_schema.concept c2 +ON ard1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 606 +AND c1.concept_id = @conceptId \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/byType.sql b/src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/byType.sql new file mode 100644 index 0000000000..c2aea0a4b1 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/byType.sql @@ -0,0 +1,11 @@ +SELECT + c1.concept_id AS "procedureConceptId", + c1.concept_name AS "procedureConceptName", + c2.concept_id AS "conceptId", + c2.concept_name AS "conceptName", + ar1.count_value AS "countValue" +FROM @results_database_schema.ACHILLES_results ar1 +INNER JOIN @vocab_database_schema.concept c1 ON ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 ON ar1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ar1.analysis_id = 605 +AND CAST(ar1.stratum_1 AS INT) = @conceptId \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/prevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/prevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..f6b99b6aff --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/prevalenceByGenderAgeYear.sql @@ -0,0 +1,41 @@ +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptName", + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS + VARCHAR) AS "trellisName", + --age decile + c2.concept_name AS "seriesName", + --gender + CAST(num_stratum_2 AS INT) AS "xCalendarYear", + -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), + 5) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM ( + SELECT + num.stratum_1 AS num_stratum_1, + num.stratum_2 AS num_stratum_2, + num.stratum_3 AS num_stratum_3, + num.stratum_4 AS num_stratum_4, + num.count_value AS num_count_value, + denom.count_value AS denom_count_value + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 604 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp + INNER JOIN @vocab_database_schema.concept c1 +ON num_stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 +ON num_stratum_3 = CAST(c2.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId \ No newline at end of file diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/prevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/prevalenceByMonth.sql new file mode 100644 index 0000000000..1c42b2e262 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/procedure/drilldown/prevalenceByMonth.sql @@ -0,0 +1,17 @@ +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptName", + num.stratum_2 AS "xCalendarMonth", + -- calendar year, note, there could be blanks + round(1000 * (1.0 * num.count_value / denom.count_value), 5) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 602) num + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 117) + denom ON num.stratum_2 = denom.stratum_1 + --calendar year + INNER JOIN @vocab_database_schema.concept c1 ON num.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId +ORDER BY CAST(num.stratum_2 AS INT ) diff --git a/src/main/resources/resources/cdmresults/sql/report/procedure/treemap.sql b/src/main/resources/resources/cdmresults/sql/report/procedure/treemap.sql new file mode 100644 index 0000000000..3a9926d24b --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/procedure/treemap.sql @@ -0,0 +1,134 @@ +SELECT + concept_hierarchy.concept_id AS "conceptId", + isNull(concept_hierarchy.level4_concept_name, 'NA') + + '||' + isNull(concept_hierarchy.level3_concept_name, 'NA') + + '||' + isNull(concept_hierarchy.level2_concept_name, 'NA') + + '||' + isNull(concept_hierarchy.proc_concept_name, 'NA') AS "conceptPath", + ar1.count_value AS "numPersons", + 1.0 * ar1.count_value / denom.count_value AS "percentPersons", + 1.0 * ar2.count_value / ar1.count_value AS "recordsPerPerson" +FROM (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 600) ar1 + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 601) ar2 + ON ar1.stratum_1 = ar2.stratum_1 + INNER JOIN + ( + SELECT + procs.concept_id, + procs.proc_concept_name, + max(proc_hierarchy.os3_concept_name) AS level2_concept_name, + max(proc_hierarchy.os2_concept_name) AS level3_concept_name, + max(proc_hierarchy.os1_concept_name) AS level4_concept_name + FROM + ( + SELECT + c1.concept_id, + v1.vocabulary_name + ' ' + c1.concept_code + ': ' + c1.concept_name AS proc_concept_name + FROM @vocab_database_schema.concept c1 + INNER JOIN @vocab_database_schema.vocabulary v1 + ON c1.vocabulary_id = v1.vocabulary_id + WHERE c1.domain_id = 'Procedure' + ) procs + LEFT JOIN + (SELECT + ca0.DESCENDANT_CONCEPT_ID, + max(ca0.ancestor_concept_id) AS ancestor_concept_id + FROM @vocab_database_schema.concept_ancestor ca0 + INNER JOIN + ( SELECT DISTINCT c2.concept_id AS os3_concept_id + FROM @vocab_database_schema.concept_ancestor ca1 + INNER JOIN + @vocab_database_schema.concept c1 + ON ca1.DESCENDANT_CONCEPT_ID = c1.concept_id + INNER JOIN + @vocab_database_schema.concept_ancestor ca2 + ON c1.concept_id = ca2.ANCESTOR_CONCEPT_ID + INNER JOIN + @vocab_database_schema.concept c2 + ON ca2.DESCENDANT_CONCEPT_ID = c2.concept_id + WHERE ca1.ancestor_concept_id = 4040390 + AND ca1.Min_LEVELS_OF_SEPARATION = 2 + AND ca2.MIN_LEVELS_OF_SEPARATION = 1 + ) t1 + + ON ca0.ANCESTOR_CONCEPT_ID = t1.os3_concept_id + + GROUP BY ca0.descendant_concept_id + + ) ca1 + ON procs.concept_id = ca1.DESCENDANT_CONCEPT_ID + LEFT JOIN + ( + SELECT + proc_by_os1.os1_concept_name, + proc_by_os2.os2_concept_name, + proc_by_os3.os3_concept_name, + proc_by_os3.os3_concept_id + FROM + (SELECT + DESCENDANT_CONCEPT_ID AS os1_concept_id, + concept_name AS os1_concept_name + FROM @vocab_database_schema.concept_ancestor ca1 + INNER JOIN + @vocab_database_schema.concept c1 + ON ca1.DESCENDANT_CONCEPT_ID = c1.concept_id + WHERE ancestor_concept_id = 4040390 + AND Min_LEVELS_OF_SEPARATION = 1 + ) proc_by_os1 + + INNER JOIN + (SELECT + max(c1.CONCEPT_ID) AS os1_concept_id, + c2.concept_id AS os2_concept_id, + c2.concept_name AS os2_concept_name + FROM @vocab_database_schema.concept_ancestor ca1 + INNER JOIN + @vocab_database_schema.concept c1 + ON ca1.DESCENDANT_CONCEPT_ID = c1.concept_id + INNER JOIN + @vocab_database_schema.concept_ancestor ca2 + ON c1.concept_id = ca2.ANCESTOR_CONCEPT_ID + INNER JOIN + @vocab_database_schema.concept c2 + ON ca2.DESCENDANT_CONCEPT_ID = c2.concept_id + WHERE ca1.ancestor_concept_id = 4040390 + AND ca1.Min_LEVELS_OF_SEPARATION = 1 + AND ca2.MIN_LEVELS_OF_SEPARATION = 1 + GROUP BY c2.concept_id, c2.concept_name + ) proc_by_os2 + ON proc_by_os1.os1_concept_id = proc_by_os2.os1_concept_id + + INNER JOIN + (SELECT + max(c1.CONCEPT_ID) AS os2_concept_id, + c2.concept_id AS os3_concept_id, + c2.concept_name AS os3_concept_name + FROM @vocab_database_schema.concept_ancestor ca1 + INNER JOIN + @vocab_database_schema.concept c1 + ON ca1.DESCENDANT_CONCEPT_ID = c1.concept_id + INNER JOIN + @vocab_database_schema.concept_ancestor ca2 + ON c1.concept_id = ca2.ANCESTOR_CONCEPT_ID + INNER JOIN + @vocab_database_schema.concept c2 + ON ca2.DESCENDANT_CONCEPT_ID = c2.concept_id + WHERE ca1.ancestor_concept_id = 4040390 + AND ca1.Min_LEVELS_OF_SEPARATION = 2 + AND ca2.MIN_LEVELS_OF_SEPARATION = 1 + GROUP BY c2.concept_id, c2.concept_name + ) proc_by_os3 + ON proc_by_os2.os2_concept_id = proc_by_os3.os2_concept_id + ) proc_hierarchy + ON ca1.ancestor_concept_id = proc_hierarchy.os3_concept_id + GROUP BY procs.concept_id, + procs.proc_concept_name + + ) concept_hierarchy + ON ar1.stratum_1 = CAST(concept_hierarchy.concept_id AS VARCHAR) + , + (SELECT count_value + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1) denom + diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/drilldown/ageAtFirstOccurrence.sql b/src/main/resources/resources/cdmresults/sql/report/visit/drilldown/ageAtFirstOccurrence.sql new file mode 100644 index 0000000000..2d37cbcc57 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/visit/drilldown/ageAtFirstOccurrence.sql @@ -0,0 +1,15 @@ +SELECT + c1.concept_id AS "conceptId", + c2.concept_name AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN @vocab_database_schema.concept c1 ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 ON ard1.stratum_2 = CAST(c2.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 206 +AND c1.concept_id = @conceptId diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/drilldown/prevalenceByGenderAgeYear.sql b/src/main/resources/resources/cdmresults/sql/report/visit/drilldown/prevalenceByGenderAgeYear.sql new file mode 100644 index 0000000000..95b9269afb --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/visit/drilldown/prevalenceByGenderAgeYear.sql @@ -0,0 +1,43 @@ +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptName", + cast(CAST(num_stratum_4 AS INT) * 10 AS VARCHAR) + '-' + cast((CAST(num_stratum_4 AS INT) + 1) * 10 - 1 AS + VARCHAR) AS "trellisName", + --age decile + c2.concept_name AS "seriesName", + --gender + CAST(num_stratum_2 AS INT) AS "xCalendarYear", + -- calendar year, note, there could be blanks + ROUND(1000 * (1.0 * num_count_value / denom_count_value), + 5) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM ( + SELECT + num.stratum_1 AS "num_stratum_1", + num.stratum_2 AS "num_stratum_2", + num.stratum_3 AS "num_stratum_3", + num.stratum_4 AS "num_stratum_4", + num.count_value AS "num_count_value", + denom.count_value AS "denom_count_value" + FROM ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 204 + AND stratum_3 IN ('8507', '8532') + ) num + INNER JOIN ( + SELECT * + FROM @results_database_schema.ACHILLES_results + WHERE analysis_id = 116 + AND stratum_2 IN ('8507', '8532') + ) denom + ON num.stratum_2 = denom.stratum_1 + AND num.stratum_3 = denom.stratum_2 + AND num.stratum_4 = denom.stratum_3 + ) tmp + INNER JOIN @vocab_database_schema.concept c1 +ON num_stratum_1 = CAST(c1.concept_id AS VARCHAR ) +INNER JOIN @vocab_database_schema.concept c2 +ON num_stratum_3 = CAST(c2.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId + + diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/drilldown/prevalenceByMonth.sql b/src/main/resources/resources/cdmresults/sql/report/visit/drilldown/prevalenceByMonth.sql new file mode 100644 index 0000000000..404ccdfe96 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/visit/drilldown/prevalenceByMonth.sql @@ -0,0 +1,17 @@ +SELECT + c1.concept_id AS "conceptId", + --all rows for all concepts, but you may split by conceptid + c1.concept_name AS "conceptName", + num.stratum_2 AS "xCalendarMonth", + -- calendar year, note, there could be blanks + 1000 * (1.0 * num.count_value / denom.count_value) AS "yPrevalence1000Pp" --prevalence, per 1000 persons +FROM + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 202) num + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 117) denom ON num.stratum_2 = denom.stratum_1 + --calendar year + INNER JOIN @vocab_database_schema.concept c1 ON num.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE c1.concept_id = @conceptId + diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/drilldown/visitDurationByType.sql b/src/main/resources/resources/cdmresults/sql/report/visit/drilldown/visitDurationByType.sql new file mode 100644 index 0000000000..05f81167c8 --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/visit/drilldown/visitDurationByType.sql @@ -0,0 +1,15 @@ +SELECT + c1.concept_id AS "conceptId", + 'Length of stay' AS "category", + ard1.min_value AS "minValue", + ard1.p10_value AS "p10Value", + ard1.p25_value AS "p25Value", + ard1.median_value AS "medianValue", + ard1.p75_value AS "p75Value", + ard1.p90_value AS "p90Value", + ard1.max_value AS "maxValue" +FROM @results_database_schema.ACHILLES_results_dist ard1 +INNER JOIN +@vocab_database_schema.concept c1 ON ard1.stratum_1 = CAST(c1.concept_id AS VARCHAR ) +WHERE ard1.analysis_id = 211 +AND CAST(ard1.stratum_1 AS INT) = @conceptId diff --git a/src/main/resources/resources/cdmresults/sql/report/visit/treemap.sql b/src/main/resources/resources/cdmresults/sql/report/visit/treemap.sql new file mode 100644 index 0000000000..f20779957b --- /dev/null +++ b/src/main/resources/resources/cdmresults/sql/report/visit/treemap.sql @@ -0,0 +1,14 @@ +SELECT + c1.concept_id AS "conceptId", + c1.concept_name AS "conceptPath", + ar1.count_value AS "numPersons", + 1.0 * ar1.count_value / denom.count_value AS "percentPersons", + 1.0 * ar2.count_value / ar1.count_value AS "recordsPerPerson" +FROM (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 200) ar1 + INNER JOIN + (SELECT * + FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 201) ar2 ON ar1.stratum_1 = ar2.stratum_1 + INNER JOIN @vocab_database_schema.concept c1 ON ar1.stratum_1 = CAST(c1.concept_id AS VARCHAR ), +( SELECT count_value FROM @results_database_schema.ACHILLES_results WHERE analysis_id = 1) denom + diff --git a/src/test/java/org/ohdsi/webapi/test/CharacterizationServiceIT.java b/src/test/java/org/ohdsi/webapi/test/CharacterizationServiceIT.java deleted file mode 100644 index 9492812d3f..0000000000 --- a/src/test/java/org/ohdsi/webapi/test/CharacterizationServiceIT.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.ohdsi.webapi.test; - -import org.junit.Test; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.util.Assert; - -/** - * Test related to characterization services - */ -public class CharacterizationServiceIT extends WebApiIT { - - public static final String NYP_COLUMBIA5_54_DEID = "NYP-Columbia5.4-deid"; - - public static String TEST_DATASOURCES = "{ \"datasources\": [ { \"name\":\"NYP-Columbia5.4-deid\", \"folder\":\"ohdsi_deid\" , \"cdmVersion\":5} ] }"; - - public static String TEST_DASHBOARD = "{\"SUMMARY\":{\"ATTRIBUTE_NAME\":[\"Source name\",\"Number of persons\"],\"ATTRIBUTE_VALUE\":[\"NYP-Columbia5.4-deid\",\"5111022\"]},\"GENDER_DATA\":{\"CONCEPT_ID\":[8507,8532],\"CONCEPT_NAME\":[\"MALE\",\"FEMALE\"],\"COUNT_VALUE\":[2244526,2854071]},\"AGE_AT_FIRST_OBSERVATION_HISTOGRAM\":{\"MIN\":0,\"MAX\":100,\"INTERVAL_SIZE\":1,\"INTERVALS\":100,\"DATA\":{\"INTERVAL_INDEX\":[221,26,87,219,19,228,85,62,53,17,226,60,28,51,0,215,232,-16,15,66,32,49,230,81,64,47,30,13,217,83,23,6,55,38,24,224,41,73,5,-6,56,223,74,-7,69,3,-2,212,235,78,12,35,67,44,1,210,-11,10,42,76,-9,71,-4,237,37,-22,75,72,-5,21,58,-8,7,239,25,22,222,225,39,40,57,8,46,63,50,216,233,65,231,82,33,16,-15,48,31,214,80,14,29,218,229,86,43,236,18,61,4,211,79,36,11,54,68,-1,238,9,52,213,27,70,84,227,234,59,45,2,-3,77,-10,34,220,20],\"COUNT_VALUE\":[6688,45565,125,7369,31982,3386,801,17293,23633,26672,3209,18970,44637,24321,231179,15012,2495,13,23904,14350,40452,24942,3046,2254,14921,25211,43308,20477,9421,1526,43950,22656,22622,32129,45382,5139,29985,7228,24275,18,21962,5478,6522,28,11063,30456,76,7920,1809,3980,20736,36596,13073,27218,63125,15437,7,18473,28895,5052,15,8785,28,1551,33867,10,5967,8047,24,37223,20961,21,20583,1392,45558,40621,6218,4111,31315,30867,21573,18887,25985,16550,25074,12955,2025,14793,2673,1922,39344,24787,13,25627,42386,9652,2813,22016,44389,8133,3516,444,28194,1657,28923,18218,26517,11117,3294,35299,19545,22838,12193,190,1378,18746,23983,9209,45125,9729,1072,3502,1920,20041,26384,39615,68,4669,11,37906,7275,34725],\"PERCENT_VALUE\":[0.00131,0.00892,2e-005,0.00144,0.00626,0.00066,0.00016,0.00338,0.00462,0.00522,0.00063,0.00371,0.00873,0.00476,0.04523,0.00294,0.00049,0,0.00468,0.00281,0.00791,0.00488,0.0006,0.00044,0.00292,0.00493,0.00847,0.00401,0.00184,0.0003,0.0086,0.00443,0.00443,0.00629,0.00888,0.00101,0.00587,0.00141,0.00475,0,0.0043,0.00107,0.00128,1e-005,0.00216,0.00596,1e-005,0.00155,0.00035,0.00078,0.00406,0.00716,0.00256,0.00533,0.01235,0.00302,0,0.00361,0.00565,0.00099,0,0.00172,1e-005,0.0003,0.00663,0,0.00117,0.00157,0,0.00728,0.0041,0,0.00403,0.00027,0.00891,0.00795,0.00122,0.0008,0.00613,0.00604,0.00422,0.0037,0.00508,0.00324,0.00491,0.00253,0.0004,0.00289,0.00052,0.00038,0.0077,0.00485,0,0.00501,0.00829,0.00189,0.00055,0.00431,0.00868,0.00159,0.00069,9e-005,0.00552,0.00032,0.00566,0.00356,0.00519,0.00218,0.00064,0.00691,0.00382,0.00447,0.00239,4e-005,0.00027,0.00367,0.00469,0.0018,0.00883,0.0019,0.00021,0.00069,0.00038,0.00392,0.00516,0.00775,1e-005,0.00091,0,0.00742,0.00142,0.00679]}},\"CUMULATIVE_DURATION\":{\"SERIES_NAME\":[\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\",\"Length of observation\"],\"X_LENGTH_OF_OBSERVATION\":[0,30,60,90,120,150,180,210,240,270,300,330,360,390,420,450,480,510,540,570,600,630,660,690,720,750,780,810,840,870,900,930,960,990,1020,1050,1080,1110,1140,1170,1200,1230,1260,1290,1320,1350,1380,1410,1440,1470,1500,1530,1560,1590,1620,1650,1680,1710,1740,1770,1800,1830,1860,1890,1920,1950,1980,2010,2040,2070,2100,2130,2160,2190,2220,2250,2280,2310,2340,2370,2400,2430,2460,2490,2520,2550,2580,2610,2640,2670,2700,2730,2760,2790,2820,2850,2880,2910,2940,2970,3000,3030,3060,3090,3120,3150,3180,3210,3240,3270,3300,3330,3360,3390,3420,3450,3480,3510,3540,3570,3600,3630,3660,3690,3720,3750,3780,3810,3840,3870,3900,3930,3960,3990,4020,4050,4080,4110,4140,4170,4200,4230,4260,4290,4320,4350,4380,4410,4440,4470,4500,4530,4560,4590,4620,4650,4680,4710,4740,4770,4800,4830,4860,4890,4920,4950,4980,5010,5040,5070,5100,5130,5160,5190,5220,5250,5280,5310,5340,5370,5400,5430,5460,5490,5520,5550,5580,5610,5640,5670,5700,5730,5760,5790,5820,5850,5880,5910,5940,5970,6000,6030,6060,6090,6120,6150,6180,6210,6240,6270,6300,6330,6360,6390,6420,6450,6480,6510,6540,6570,6600,6630,6660,6690,6720,6750,6780,6810,6840,6870,6900,6930,6960,6990,7020,7050,7080,7110,7140,7170,7200,7230,7260,7290,7320,7350,7380,7410,7440,7470,7500,7530,7560,7590,7620,7650,7680,7710,7740,7770,7800,7830,7860,7890,7920,7950,7980,8010,8040,8070,8100,8130,8160,8190,8220,8250,8280,8310,8340,8370,8400,8430,8460,8490,8520,8550,8580,8610,8640,8670,8700,8730,8760,8790,8820,8850,8880,8910,8940,8970,9000,9030,9060,9090,9120,9150,9180,9210,9240,9270,9300,9330,9360,9390,9420,9450,9480,9510,9540,9570,9600,9630,9660,9690,9720,9750,9780,9810,9840,9870,9900,9930,9960,9990,10020,10050,10080,10110,10140,10170,10200,10230,10260,10290,10320,10350,10380,10410,10440,10470,10500,10530,10560,10590,10620,10650,10680,10710,10740,10770,10800,10830,10860,10890,10920],\"Y_PERCENT_PERSONS\":[0.4561,0.24656,0.23307,0.22473,0.21832,0.21314,0.20867,0.20418,0.20004,0.19651,0.19324,0.19022,0.18722,0.18378,0.18087,0.17817,0.17564,0.17327,0.17096,0.16868,0.16655,0.16448,0.16247,0.16051,0.1585,0.1563,0.15429,0.15244,0.15065,0.14888,0.14723,0.14555,0.14393,0.14236,0.14087,0.13936,0.13782,0.13627,0.13476,0.13328,0.13192,0.13058,0.1293,0.12798,0.1267,0.12545,0.12423,0.12303,0.12187,0.12063,0.11937,0.11819,0.11704,0.11592,0.11482,0.11373,0.11266,0.11158,0.11058,0.10958,0.10855,0.10749,0.10646,0.10542,0.10442,0.10345,0.10251,0.10155,0.1006,0.09969,0.09881,0.09793,0.09709,0.09625,0.09536,0.09455,0.09373,0.09292,0.0921,0.09131,0.09055,0.08977,0.08902,0.08827,0.08753,0.08677,0.08601,0.08527,0.08455,0.08382,0.08312,0.08244,0.08175,0.08108,0.08038,0.07971,0.07907,0.07842,0.07774,0.07708,0.07644,0.07581,0.07518,0.07454,0.07392,0.07332,0.07271,0.07211,0.07152,0.07095,0.07034,0.06975,0.06915,0.06858,0.06802,0.06746,0.0669,0.06635,0.06582,0.06528,0.06476,0.06424,0.0637,0.06318,0.06264,0.06212,0.06162,0.0611,0.06059,0.06009,0.05958,0.0591,0.05862,0.05813,0.05764,0.05713,0.05665,0.05616,0.0557,0.05524,0.05477,0.0543,0.05383,0.05338,0.05292,0.05246,0.05201,0.05156,0.0511,0.05065,0.05022,0.04979,0.04936,0.04896,0.04856,0.04815,0.04774,0.04733,0.04692,0.04652,0.04611,0.04572,0.04533,0.04494,0.04453,0.04413,0.04372,0.04335,0.04297,0.04259,0.04221,0.04184,0.04146,0.04109,0.04072,0.04035,0.04,0.03965,0.0393,0.03895,0.03859,0.03825,0.03789,0.03754,0.03719,0.03685,0.03651,0.03618,0.03585,0.03551,0.03519,0.03486,0.03455,0.03423,0.03391,0.03359,0.03328,0.03295,0.03262,0.03231,0.032,0.0317,0.03139,0.03108,0.03078,0.03047,0.03015,0.02984,0.02954,0.02925,0.02895,0.02865,0.02835,0.02804,0.02774,0.02744,0.02716,0.02688,0.02659,0.0263,0.02603,0.02575,0.02546,0.02519,0.02493,0.02466,0.02439,0.02413,0.02387,0.0236,0.02334,0.02307,0.02281,0.02255,0.02229,0.02205,0.02181,0.02156,0.02131,0.02106,0.02083,0.02059,0.02035,0.02012,0.01988,0.01965,0.01942,0.01919,0.01897,0.01876,0.01855,0.01834,0.0181,0.01787,0.01763,0.01741,0.01718,0.01696,0.01675,0.01653,0.01633,0.01612,0.01589,0.01569,0.01548,0.01527,0.01506,0.01485,0.01465,0.01444,0.01422,0.01401,0.0138,0.01359,0.01339,0.01318,0.01298,0.01278,0.01258,0.01237,0.01216,0.01196,0.01175,0.01155,0.01135,0.01115,0.01095,0.01075,0.01056,0.01035,0.01015,0.00996,0.00975,0.00956,0.00937,0.00917,0.00897,0.00878,0.00859,0.00841,0.00824,0.00806,0.0079,0.00775,0.00759,0.00744,0.00728,0.00712,0.00697,0.00681,0.00666,0.00651,0.00637,0.00623,0.00607,0.00593,0.00578,0.00564,0.0055,0.00537,0.00522,0.00508,0.00495,0.00481,0.00467,0.00455,0.00442,0.0043,0.00416,0.00404,0.0039,0.00377,0.00364,0.00352,0.00339,0.00326,0.00313,0.003,0.00286,0.00273,0.0026,0.00248,0.00236,0.00222,0.00209,0.00197,0.00184,0.00171,0.00159,0.00145,0.00131,0.00118,0.00105,0.00091,0.00078,0.00066,0.00054,0.00043,0.00033,0.00025,0.00018,0.00011,7e-005,3e-005,1e-005]},\"OBSERVED_BY_MONTH\":{\"MONTH_YEAR\":[198608,198610,198708,198710,198808,198810,198908,198910,199008,199010,199012,199110,199112,199210,199212,199310,199312,199410,199412,199510,199512,199610,199612,199710,199712,199812,199912,200012,200112,200212,200312,200412,200512,201101,201201,201301,201401,201501,198611,198803,198903,199003,199103,199203,199204,199303,199304,199403,199404,199503,199504,199603,199604,199703,199704,199803,199804,199903,199904,200003,200004,200103,200104,200203,200204,200304,200307,200404,200407,200504,200507,200604,200607,200608,200707,200708,200807,200808,200907,200908,201007,201008,201107,201108,201207,201208,201307,201308,201407,201408,201507,201508,198604,198606,198704,198706,198804,198806,198904,198906,199004,199006,199104,199106,199108,199206,199208,199306,199308,199406,199408,199506,199508,199601,199606,199608,199701,199706,199708,199801,199806,199808,199810,199901,199908,199910,200001,200008,200010,200101,200108,200110,200201,200208,200210,200301,200303,200308,200310,200401,200403,200408,200410,200501,200503,200508,200510,200601,200603,200610,200612,200701,200703,200710,200712,200801,200803,200810,200812,200901,200903,200910,200912,201001,201003,201005,201010,201012,201103,201105,201110,201112,201203,201205,201210,201212,201303,201305,201312,201403,201405,201412,201503,201505,201512,198607,198609,198709,198711,198809,198811,198909,198911,199009,199011,199109,199111,199209,199211,199309,199311,199409,199411,199511,199611,199711,199811,199911,200011,200111,201502,198605,198612,198705,198712,198805,198812,198905,198912,199005,199105,199205,199305,199405,199509,199609,199709,199809,199909,200002,200009,200102,200109,200202,200209,200302,200309,200402,200409,200502,200509,200602,200609,200702,200709,200802,200809,200902,200909,201002,201102,201202,201302,201402,201406,201506,198602,198701,198702,198801,198802,198901,198902,199001,199002,199101,199102,199201,199202,199301,199302,199401,199402,199501,199502,199505,199602,199605,199702,199705,199802,199805,199902,199905,199906,200005,200006,200105,200106,200205,200206,200305,200306,200405,200406,200505,200506,200605,200606,200705,200706,200805,200806,200905,200906,201006,201009,201106,201109,201206,201209,201306,201309,201310,201409,201410,201509,201510,198603,198703,198707,198807,198907,199007,199107,199207,199307,199407,199507,199607,199707,199807,199907,200007,200107,200207,200211,200311,200411,200511,200611,200704,200711,200804,200811,200904,200911,201004,201011,201104,201111,201204,201211,201304,201311,201404,201411,201504,201511],\"COUNT_VALUE\":[32413,45943,98340,104821,130659,135067,155603,159853,179771,183354,187062,211646,216928,236224,239054,252229,254525,265837,267794,277855,279923,292794,295488,307576,309653,321787,333393,339806,345053,356381,367214,376976,382358,355800,335338,309885,273346,210036,53222,118694,145309,170093,193642,223755,226010,243185,244652,257901,259116,270793,271914,283438,284743,299674,301136,312814,313872,325036,326133,335380,336022,340878,341314,347479,348531,359825,362667,370723,373107,379481,380792,382845,382682,382620,380424,380235,377491,377114,372763,372126,362960,361707,346592,344918,323487,321207,293690,290551,247877,242545,145357,128739,10129,20275,82961,91256,121282,126220,147438,151507,172102,175911,196153,201336,206507,229665,233035,247286,249734,261386,263596,274040,275917,281026,287287,290037,297084,303327,305349,310678,315715,317713,319828,322974,329922,331450,334138,338275,339091,340158,342727,343825,345811,352389,354360,357271,359004,363560,365373,368001,369697,373966,375444,377618,378752,381244,381987,382616,382663,382287,382016,381890,381343,379793,379296,378889,378539,376388,375845,375522,374614,370716,369296,368408,366354,364600,359528,357097,352999,349965,341182,337268,331273,327326,316741,312308,304845,299455,276999,265960,257145,217897,192839,171875,2822,26028,39148,101814,107907,132866,137177,157859,161984,181640,185354,209186,214396,234767,237795,251081,253510,264807,266910,279006,294302,308794,320948,332523,339521,344610,202630,14945,60262,87217,110752,123744,139123,149370,164061,173989,198589,227785,245975,260158,276934,291484,306528,318777,330765,335032,338765,340931,343386,346924,353497,358437,364530,369200,374756,378559,381768,383013,382608,382032,380133,378828,376843,375492,371593,367722,354894,333583,307835,270116,252975,159603,2542,67246,73496,113485,116275,141215,143511,166181,168331,189191,191648,219324,221871,240590,242153,255685,257092,268826,270075,272910,282321,285873,298760,302237,312031,314592,324197,327007,327996,336553,337335,341579,341945,349348,350472,360721,361807,371524,372354,380057,380615,382717,382754,380892,380756,377983,377820,373965,373583,364013,360790,348334,343165,325656,319168,296737,287432,284024,237310,231122,110024,85816,5757,78175,94801,128464,153489,177798,203886,231303,248461,262425,274974,288615,304264,316639,328806,337798,342273,351415,355508,366414,376385,382307,382335,381315,379641,378391,376205,374474,370140,365688,358480,351720,339463,329417,314736,302252,280565,261782,224879,183073,55315],\"PERCENT_VALUE\":[0.00634,0.00899,0.01924,0.02051,0.02556,0.02643,0.03044,0.03128,0.03517,0.03587,0.0366,0.04141,0.04244,0.04622,0.04677,0.04935,0.0498,0.05201,0.0524,0.05436,0.05477,0.05729,0.05781,0.06018,0.06059,0.06296,0.06523,0.06648,0.06751,0.06973,0.07185,0.07376,0.07481,0.06961,0.06561,0.06063,0.05348,0.04109,0.01041,0.02322,0.02843,0.03328,0.03789,0.04378,0.04422,0.04758,0.04787,0.05046,0.0507,0.05298,0.0532,0.05546,0.05571,0.05863,0.05892,0.0612,0.06141,0.0636,0.06381,0.06562,0.06574,0.06669,0.06678,0.06799,0.06819,0.0704,0.07096,0.07253,0.073,0.07425,0.0745,0.07491,0.07487,0.07486,0.07443,0.0744,0.07386,0.07378,0.07293,0.07281,0.07102,0.07077,0.06781,0.06749,0.06329,0.06285,0.05746,0.05685,0.0485,0.04746,0.02844,0.02519,0.00198,0.00397,0.01623,0.01785,0.02373,0.0247,0.02885,0.02964,0.03367,0.03442,0.03838,0.03939,0.0404,0.04494,0.04559,0.04838,0.04886,0.05114,0.05157,0.05362,0.05398,0.05498,0.05621,0.05675,0.05813,0.05935,0.05974,0.06079,0.06177,0.06216,0.06258,0.06319,0.06455,0.06485,0.06538,0.06619,0.06635,0.06655,0.06706,0.06727,0.06766,0.06895,0.06933,0.0699,0.07024,0.07113,0.07149,0.072,0.07233,0.07317,0.07346,0.07388,0.0741,0.07459,0.07474,0.07486,0.07487,0.0748,0.07474,0.07472,0.07461,0.07431,0.07421,0.07413,0.07406,0.07364,0.07354,0.07347,0.0733,0.07253,0.07225,0.07208,0.07168,0.07134,0.07034,0.06987,0.06907,0.06847,0.06675,0.06599,0.06482,0.06404,0.06197,0.0611,0.05964,0.05859,0.0542,0.05204,0.05031,0.04263,0.03773,0.03363,0.00055,0.00509,0.00766,0.01992,0.02111,0.026,0.02684,0.03089,0.03169,0.03554,0.03627,0.04093,0.04195,0.04593,0.04653,0.04913,0.0496,0.05181,0.05222,0.05459,0.05758,0.06042,0.0628,0.06506,0.06643,0.06742,0.03965,0.00292,0.01179,0.01706,0.02167,0.02421,0.02722,0.02923,0.0321,0.03404,0.03886,0.04457,0.04813,0.0509,0.05418,0.05703,0.05997,0.06237,0.06472,0.06555,0.06628,0.06671,0.06719,0.06788,0.06916,0.07013,0.07132,0.07224,0.07332,0.07407,0.0747,0.07494,0.07486,0.07475,0.07438,0.07412,0.07373,0.07347,0.0727,0.07195,0.06944,0.06527,0.06023,0.05285,0.0495,0.03123,0.0005,0.01316,0.01438,0.0222,0.02275,0.02763,0.02808,0.03251,0.03293,0.03702,0.0375,0.04291,0.04341,0.04707,0.04738,0.05003,0.0503,0.0526,0.05284,0.0534,0.05524,0.05593,0.05845,0.05913,0.06105,0.06155,0.06343,0.06398,0.06417,0.06585,0.066,0.06683,0.0669,0.06835,0.06857,0.07058,0.07079,0.07269,0.07285,0.07436,0.07447,0.07488,0.07489,0.07452,0.0745,0.07395,0.07392,0.07317,0.07309,0.07122,0.07059,0.06815,0.06714,0.06372,0.06245,0.05806,0.05624,0.05557,0.04643,0.04522,0.02153,0.01679,0.00113,0.0153,0.01855,0.02513,0.03003,0.03479,0.03989,0.04526,0.04861,0.05134,0.0538,0.05647,0.05953,0.06195,0.06433,0.06609,0.06697,0.06876,0.06956,0.07169,0.07364,0.0748,0.07481,0.07461,0.07428,0.07403,0.07361,0.07327,0.07242,0.07155,0.07014,0.06882,0.06642,0.06445,0.06158,0.05914,0.05489,0.05122,0.044,0.03582,0.01082]}}\n"; - - @Value("${characterization.endpoint}") - private String endpointCharacterizations; - - /** - * @throws Exception - */ - @Test - public void testDataSources() throws Exception { - final ResponseEntity getEntity = getRestTemplate().getForEntity(this.endpointCharacterizations + "/datasources", - String.class); - assertOk(getEntity); - log.info(getEntity.getBody()); - - Assert.state(getEntity.equals(CharacterizationServiceIT.TEST_DATASOURCES)); - } - - - /** - * @throws Exception - */ - @Test - public void testDashboard() throws Exception { - log.info("Testing " + endpointCharacterizations + " endpoint"); - final ResponseEntity getEntity = getRestTemplate().getForEntity(this.endpointCharacterizations + "/" + NYP_COLUMBIA5_54_DEID + "/dashboard", String.class); - assertOk(getEntity); - log.info(getEntity.getBody()); - Assert.state(getEntity.equals(CharacterizationServiceIT.TEST_DASHBOARD)); - - } - - private void assertOk(final ResponseEntity entity) { - Assert.state(entity.getStatusCode() == HttpStatus.OK); - } - -// @Test -// public void testHeel() { -// log.info("Testing " + this.endpointCharacterizations + "/heel" + " endpoint"); -// final ResponseEntity entity = getRestTemplate().getForEntity(this.endpointCharacterizations + "/NYP-Columbia5.4-deid/" + "heel", String.class); -// } - -} diff --git a/src/test/resources/application-test.properties b/src/test/resources/application-test.properties index a2ee1b0803..a3041fba0a 100644 --- a/src/test/resources/application-test.properties +++ b/src/test/resources/application-test.properties @@ -21,8 +21,6 @@ jobservice.endpoint.job=${jobservice.endpoint}/{instanceId} jobservice.endpoint.jobexecution=${jobservice.endpoint.job}/execution/{executionId} jobservice.endpoint.jobexecution.alt=${jobservice.endpoint}/execution/{executionId} -#Characterization Service -characterization.endpoint=${baseUri}/characterization