repo stringclasses 1k
values | file_url stringlengths 96 373 | file_path stringlengths 11 294 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 6
values | commit_sha stringclasses 1k
values | retrieved_at stringdate 2026-01-04 14:45:56 2026-01-04 18:30:23 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/HierarchicalConceptPrevalenceMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/HierarchicalConceptPrevalenceMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.HierarchicalConceptRecord;
import org.springframework.jdbc.core.RowMapper;
public class HierarchicalConceptPrevalenceMapper implements RowMapper<HierarchicalConceptRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/CohortAttributeMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/CohortAttributeMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.CohortAttribute;
import org.springframework.jdbc.core.RowMapper;
public class CohortAttributeMapper implements RowMapper<CohortAttribute> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/PrevalanceConceptNameMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/PrevalanceConceptNameMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.PrevalenceRecord;
import org.springframework.jdbc.core.RowMapper;
public class PrevalanceConceptNameMapper implements RowMapper<PrevalenceRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/HierarchicalConceptMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/HierarchicalConceptMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.HierarchicalConceptRecord;
import org.springframework.jdbc.core.RowMapper;
public class HierarchicalConceptMapper implements RowMapper<HierarchicalConceptRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/package-info.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/package-info.java | /**
* SQL mappers
*/
package org.ohdsi.webapi.cohortresults.mapper; | java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/ConceptDistributionMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/ConceptDistributionMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.ConceptDistributionRecord;
import org.springframework.jdbc.core.RowMapper;
public class ConceptDistributionMapper implements RowMapper<ConceptDistributionRecord>{
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/ProfileSampleMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/ProfileSampleMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import org.ohdsi.webapi.cohortresults.ProfileSampleRecord;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
public class ProfileSampleMapper implements RowMapper<ProfileSampleRecord> {
@Override
public ProfileSampleRecord mapRow(ResultSet rs, int rowNum)
throws SQLException {
ProfileSampleRecord record = new ProfileSampleRecord();
record.setAgeGroup (rs.getInt("age_group"));
record.setGenderConceptId(rs.getLong("gender_concept_id"));
record.setPersonId(rs.getLong("person_id"));
return record;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/HierarchicalConceptEraMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/HierarchicalConceptEraMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.HierarchicalConceptRecord;
import org.springframework.jdbc.core.RowMapper;
public class HierarchicalConceptEraMapper implements RowMapper<HierarchicalConceptRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/TornadoMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/TornadoMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import org.ohdsi.webapi.cohortresults.TornadoRecord;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
public class TornadoMapper implements RowMapper<TornadoRecord> {
@Override
public TornadoRecord mapRow(ResultSet rs, int rowNum)
throws SQLException {
TornadoRecord record = new TornadoRecord();
record.setAgeGroup(rs.getInt("age_group"));
record.setGenderConceptId(rs.getLong("gender_concept_id"));
record.setPersonCount(rs.getLong("person_count"));
return record;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/AnalysisResultsMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/AnalysisResultsMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.model.results.AnalysisResults;
import org.springframework.jdbc.core.RowMapper;
/**
*
*/
public class AnalysisResultsMapper implements RowMapper<AnalysisResults> {
/**
* @see org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, int)
*/
@Override
public AnalysisResults mapRow(ResultSet rs, int rowNum) throws SQLException {
AnalysisResults ar = new AnalysisResults();
ar.setAnalysisId(rs.getInt("ANALYSIS_ID"));
ar.setCohortDefinitionId(rs.getInt("COHORT_DEFINITION_ID"));
ar.setStratum1(rs.getString("STRATUM_1"));
ar.setStratum2(rs.getString("STRATUM_2"));
ar.setStratum3(rs.getString("STRATUM_3"));
ar.setStratum4(rs.getString("STRATUM_4"));
ar.setStratum5(rs.getString("STRATUM_5"));
ar.setCountValue(rs.getInt("count_value"));
return ar;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/ConceptCountMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/ConceptCountMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.ConceptCountRecord;
import org.springframework.jdbc.core.RowMapper;
public class ConceptCountMapper implements RowMapper<ConceptCountRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/ConceptObservationCountMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/ConceptObservationCountMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.ConceptCountRecord;
import org.springframework.jdbc.core.RowMapper;
public class ConceptObservationCountMapper implements RowMapper<ConceptCountRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/PrevalanceConceptMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/PrevalanceConceptMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.PrevalenceRecord;
import org.springframework.jdbc.core.RowMapper;
public class PrevalanceConceptMapper implements RowMapper<PrevalenceRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/MonthObservationMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/MonthObservationMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.MonthObservationRecord;
import org.springframework.jdbc.core.RowMapper;
public class MonthObservationMapper implements RowMapper<MonthObservationRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/PrevalanceMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/PrevalanceMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.PrevalenceRecord;
import org.springframework.jdbc.core.RowMapper;
public class PrevalanceMapper implements RowMapper<PrevalenceRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/ObservationPeriodMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/ObservationPeriodMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.ObservationPeriodRecord;
import org.springframework.jdbc.core.RowMapper;
public class ObservationPeriodMapper implements RowMapper<ObservationPeriodRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/ConceptQuartileMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/ConceptQuartileMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.ConceptQuartileRecord;
import org.springframework.jdbc.core.RowMapper;
public class ConceptQuartileMapper implements RowMapper<ConceptQuartileRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/CohortStatsMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/CohortStatsMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.CohortStatsRecord;
import org.springframework.jdbc.core.RowMapper;
public class CohortStatsMapper implements RowMapper<CohortStatsRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/ConceptDecileMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/ConceptDecileMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.ConceptDecileRecord;
import org.springframework.jdbc.core.RowMapper;
public class ConceptDecileMapper implements RowMapper<ConceptDecileRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/SeriesPerPersonMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/SeriesPerPersonMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.SeriesPerPerson;
import org.springframework.jdbc.core.RowMapper;
public class SeriesPerPersonMapper implements RowMapper<SeriesPerPerson> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortresults/mapper/ConceptDecileCountsMapper.java | src/main/java/org/ohdsi/webapi/cohortresults/mapper/ConceptDecileCountsMapper.java | package org.ohdsi.webapi.cohortresults.mapper;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.ohdsi.webapi.cohortresults.ConceptDecileRecord;
import org.springframework.jdbc.core.RowMapper;
public class ConceptDecileCountsMapper implements RowMapper<ConceptDecileRecord> {
@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;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortExt.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CohortExt.java | package org.ohdsi.webapi.cohortdefinition;
import org.ohdsi.analysis.Cohort;
public interface CohortExt extends CohortMetadataExt, Cohort {
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/ExpressionType.java | src/main/java/org/ohdsi/webapi/cohortdefinition/ExpressionType.java | /*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.cohortdefinition;
/**
*
* @author cknoll1
*/
public enum ExpressionType
{
SIMPLE_EXPRESSION,
CUSTOM_SQL,
EXTERNAL_SOURCED
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortMetadataExt.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CohortMetadataExt.java | package org.ohdsi.webapi.cohortdefinition;
import org.ohdsi.analysis.CohortMetadata;
import org.ohdsi.webapi.tag.dto.TagDTO;
import java.util.List;
import java.util.Set;
public interface CohortMetadataExt extends CohortMetadata {
Set<TagDTO> getTags();
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/InclusionRuleReport.java | src/main/java/org/ohdsi/webapi/cohortdefinition/InclusionRuleReport.java | /*
* Copyright 2015 Observational Health Data Sciences and Informatics [OHDSI.org].
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.cohortdefinition;
import java.util.List;
import org.ohdsi.webapi.cohortcharacterization.report.Report;
/**
*
* @author Chris Knoll <cknoll@ohdsi.org>
*/
public class InclusionRuleReport {
public static class Summary {
public long baseCount;
public long finalCount;
public long lostCount;
public String percentMatched;
}
public static class InclusionRuleStatistic
{
public int id;
public String name;
public String percentExcluded;
public String percentSatisfying;
public long countSatisfying;
}
public Summary summary;
public List<InclusionRuleStatistic> inclusionRuleStats;
public String treemapData;
public List<Report> demographicsStats;
public Float prevalenceThreshold = 0.01f;
public Boolean showEmptyResults = false;
public int count = 0;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationRequestBuilder.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationRequestBuilder.java | package org.ohdsi.webapi.cohortdefinition;
import org.ohdsi.circe.cohortdefinition.CohortExpression;
import org.ohdsi.webapi.source.Source;
public class CohortGenerationRequestBuilder {
private CohortExpression expression;
private Source source;
private String sessionId;
private String targetSchema;
private Integer targetId;
public CohortGenerationRequestBuilder(String sessionId, String targetSchema) {
this.sessionId = sessionId;
this.targetSchema = targetSchema;
}
public CohortGenerationRequestBuilder withSource(Source source) {
this.source = source;
return this;
}
public CohortGenerationRequestBuilder withExpression(CohortExpression expression) {
this.expression = expression;
return this;
}
public CohortGenerationRequestBuilder withTargetId(Integer targetId) {
this.targetId = targetId;
return this;
}
public CohortGenerationRequest build() {
if (this.source == null || this.expression == null || this.targetId == null) {
throw new RuntimeException("CohortGenerationRequest should contain non-null expression, source and targetId");
}
return new CohortGenerationRequest(expression, source, sessionId, targetId, targetSchema);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationInfoId.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationInfoId.java | /*
* Copyright 2015 Observational Health Data Sciences and Informatics [OHDSI.org].
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.cohortdefinition;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;
/**
*
* @author Chris Knoll <cknoll@ohdsi.org>
*/
@Embeddable
public class CohortGenerationInfoId implements Serializable {
private static final long serialVersionUID = 1L;
public CohortGenerationInfoId() {
}
public CohortGenerationInfoId(Integer cohortDefinitionId, Integer sourceId) {
this.cohortDefinitionId = cohortDefinitionId;
this.sourceId = sourceId;
}
@Column(name = "id", insertable = false, updatable = false)
private Integer cohortDefinitionId;
@Column(name = "source_id")
private Integer sourceId;
public Integer getCohortDefinitionId() {
return cohortDefinitionId;
}
public void setCohortDefinitionId(Integer cohortDefinitionId) {
this.cohortDefinitionId = cohortDefinitionId;
}
public Integer getSourceId() {
return sourceId;
}
public void setSourceId(Integer sourceId) {
this.sourceId = sourceId;
}
public boolean equals(Object o) {
return ((o instanceof CohortGenerationInfoId)
&& cohortDefinitionId.equals(((CohortGenerationInfoId) o).getCohortDefinitionId())
&& sourceId.equals(((CohortGenerationInfoId) o).getSourceId()));
}
public int hashCode() {
return cohortDefinitionId + sourceId;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/GenerateCohortTasklet.java | src/main/java/org/ohdsi/webapi/cohortdefinition/GenerateCohortTasklet.java | /*
* Copyright 2015 Observational Health Data Sciences and Informatics <OHDSI.org>.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.cohortdefinition;
import org.ohdsi.circe.helper.ResourceHelper;
import org.ohdsi.cohortcharacterization.CCQueryBuilder;
import org.ohdsi.sql.BigQuerySparkTranslate;
import org.ohdsi.sql.SqlRender;
import org.ohdsi.sql.SqlSplit;
import org.ohdsi.sql.SqlTranslate;
import org.ohdsi.webapi.cohortcharacterization.domain.CcFeAnalysisEntity;
import org.ohdsi.webapi.cohortcharacterization.domain.CohortCharacterizationEntity;
import org.ohdsi.webapi.common.generation.CancelableTasklet;
import org.ohdsi.webapi.common.generation.GenerationUtils;
import org.ohdsi.webapi.feanalysis.domain.FeAnalysisEntity;
import org.ohdsi.webapi.feanalysis.repository.FeAnalysisEntityRepository;
import org.ohdsi.webapi.generationcache.GenerationCacheHelper;
import org.ohdsi.webapi.shiro.Entities.UserRepository;
import org.ohdsi.webapi.source.Source;
import org.ohdsi.webapi.source.SourceService;
import org.ohdsi.webapi.util.CancelableJdbcTemplate;
import org.ohdsi.webapi.util.SessionUtils;
import org.ohdsi.webapi.util.SourceUtils;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.StoppableTasklet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.support.TransactionTemplate;
import com.google.common.collect.ImmutableList;
import com.odysseusinc.arachne.commons.types.DBMSType;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.ohdsi.webapi.Constants.Params.*;
/**
*
* @author Chris Knoll <cknoll@ohdsi.org>
*/
public class GenerateCohortTasklet extends CancelableTasklet implements StoppableTasklet {
private final static String copyGenerationIntoCohortTableSql = ResourceHelper.GetResourceAsString("/resources/cohortdefinition/sql/copyGenerationIntoCohortTableSql.sql");
private final GenerationCacheHelper generationCacheHelper;
private final CohortDefinitionRepository cohortDefinitionRepository;
private final SourceService sourceService;
private final FeAnalysisEntityRepository feAnalysisRepository;
public GenerateCohortTasklet(final CancelableJdbcTemplate jdbcTemplate, final TransactionTemplate transactionTemplate,
final GenerationCacheHelper generationCacheHelper,
final CohortDefinitionRepository cohortDefinitionRepository, final SourceService sourceService) {
super(LoggerFactory.getLogger(GenerateCohortTasklet.class), jdbcTemplate, transactionTemplate);
this.generationCacheHelper = generationCacheHelper;
this.cohortDefinitionRepository = cohortDefinitionRepository;
this.sourceService = sourceService;
this.feAnalysisRepository = null;
}
public GenerateCohortTasklet(
final CancelableJdbcTemplate jdbcTemplate,
final TransactionTemplate transactionTemplate,
final GenerationCacheHelper generationCacheHelper,
final CohortDefinitionRepository cohortDefinitionRepository,
final SourceService sourceService, final FeAnalysisEntityRepository feAnalysisRepository
) {
super(LoggerFactory.getLogger(GenerateCohortTasklet.class), jdbcTemplate, transactionTemplate);
this.generationCacheHelper = generationCacheHelper;
this.cohortDefinitionRepository = cohortDefinitionRepository;
this.sourceService = sourceService;
this.feAnalysisRepository = feAnalysisRepository;
}
@Override
protected String[] prepareQueries(ChunkContext chunkContext, CancelableJdbcTemplate jdbcTemplate) {
Map<String, Object> jobParams = chunkContext.getStepContext().getJobParameters();
String[] defaultQueries = prepareQueriesDefault(jobParams, jdbcTemplate);
Boolean demographicStat = jobParams.get(DEMOGRAPHIC_STATS) == null ? null
: Boolean.valueOf((String) jobParams.get(DEMOGRAPHIC_STATS));
if (demographicStat != null && demographicStat.booleanValue()) {
String[] demographicsQueries = prepareQueriesDemographic(chunkContext, jdbcTemplate);
return Stream.concat(Arrays.stream(defaultQueries), Arrays.stream(demographicsQueries)).toArray(String[]::new);
}
return defaultQueries;
}
private String[] prepareQueriesDemographic(ChunkContext chunkContext, CancelableJdbcTemplate jdbcTemplate) {
Map<String, Object> jobParams = chunkContext.getStepContext().getJobParameters();
CohortCharacterizationEntity cohortCharacterization = new CohortCharacterizationEntity();
Integer cohortDefinitionId = Integer.valueOf(jobParams.get(COHORT_DEFINITION_ID).toString());
CohortDefinition cohortDefinition = cohortDefinitionRepository.findOneWithDetail(cohortDefinitionId);
cohortCharacterization.setCohortDefinitions(new HashSet<>(Arrays.asList(cohortDefinition)));
// Get FE Analysis Demographic (Gender, Age, Race,)
Set<FeAnalysisEntity> feAnalysis = feAnalysisRepository.findByListIds(Arrays.asList(70, 72, 74, 77));
Set<CcFeAnalysisEntity> ccFeAnalysis = feAnalysis.stream().map(a -> {
CcFeAnalysisEntity ccA = new CcFeAnalysisEntity();
ccA.setCohortCharacterization(cohortCharacterization);
ccA.setFeatureAnalysis(a);
return ccA;
}).collect(Collectors.toSet());
cohortCharacterization.setFeatureAnalyses(ccFeAnalysis);
final Long jobId = chunkContext.getStepContext().getStepExecution().getJobExecution().getId();
final Integer sourceId = Integer.valueOf(jobParams.get(SOURCE_ID).toString());
final Source source = sourceService.findBySourceId(sourceId);
final String cohortTable = String.format("%s.%s", SourceUtils.getTempQualifier(source), jobParams.get(TARGET_TABLE).toString());
final String sessionId = jobParams.get(SESSION_ID).toString();
final String tempSchema = SourceUtils.getTempQualifier(source);
boolean includeAnnual = false;
boolean includeTemporal = false;
CCQueryBuilder ccQueryBuilder = new CCQueryBuilder(cohortCharacterization, cohortTable, sessionId,
SourceUtils.getCdmQualifier(source), SourceUtils.getResultsQualifier(source),
SourceUtils.getVocabularyQualifier(source), tempSchema, jobId, includeAnnual, includeTemporal);
String sql = ccQueryBuilder.build();
/*
* There is an issue with temp tables on sql server: Temp tables scope is
* session or stored procedure. To execute PreparedStatement sql server
* uses stored procedure <i>sp_executesql</i> and this is the reason why
* multiple PreparedStatements cannot share the same local temporary
* table.
*
* On the other side, temp tables cannot be re-used in the same
* PreparedStatement, e.g. temp table cannot be created, used, dropped and
* created again in the same PreparedStatement because sql optimizator
* detects object already exists and fails. When is required to re-use
* temp table it should be separated to several PreparedStatements.
*
* An option to use global temp tables also doesn't work since such tables
* can be not supported / disabled.
*
* Therefore, there are two ways: - either precisely group SQLs into
* statements so that temp tables aren't re-used in a single statement, -
* or use ‘permanent temporary tables’
*
* The second option looks better since such SQL could be exported and
* executed manually, which is not the case with the first option.
*/
if (ImmutableList.of(DBMSType.MS_SQL_SERVER.getOhdsiDB(), DBMSType.PDW.getOhdsiDB())
.contains(source.getSourceDialect())) {
sql = sql.replaceAll("#", tempSchema + "." + sessionId + "_").replaceAll("tempdb\\.\\.", "");
}
final String translatedSql = SqlTranslate.translateSql(sql, source.getSourceDialect(), sessionId, tempSchema);
return SqlSplit.splitSql(translatedSql);
}
private String[] prepareQueriesDefault(Map<String, Object> jobParams, CancelableJdbcTemplate jdbcTemplate) {
Integer cohortDefinitionId = Integer.valueOf(jobParams.get(COHORT_DEFINITION_ID).toString());
Integer sourceId = Integer.parseInt(jobParams.get(SOURCE_ID).toString());
String targetSchema = jobParams.get(TARGET_DATABASE_SCHEMA).toString();
String sessionId = jobParams.getOrDefault(SESSION_ID, SessionUtils.sessionId()).toString();
CohortDefinition cohortDefinition = cohortDefinitionRepository.findOneWithDetail(cohortDefinitionId);
Source source = sourceService.findBySourceId(sourceId);
CohortGenerationRequestBuilder generationRequestBuilder = new CohortGenerationRequestBuilder(sessionId,
targetSchema);
int designHash = this.generationCacheHelper.computeHash(cohortDefinition.getDetails().getExpression());
CohortGenerationUtils.insertInclusionRules(cohortDefinition, source, designHash, targetSchema, sessionId,
jdbcTemplate);
GenerationCacheHelper.CacheResult res = generationCacheHelper.computeCacheIfAbsent(cohortDefinition, source,
generationRequestBuilder,
(resId, sqls) -> generationCacheHelper.runCancelableCohortGeneration(jdbcTemplate, stmtCancel, sqls));
String sql = SqlRender.renderSql(copyGenerationIntoCohortTableSql,
new String[] { RESULTS_DATABASE_SCHEMA, COHORT_DEFINITION_ID, DESIGN_HASH },
new String[] { targetSchema, cohortDefinition.getId().toString(), res.getIdentifier().toString() });
sql = SqlTranslate.translateSql(sql, source.getSourceDialect());
return SqlSplit.splitSql(sql);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationRequest.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationRequest.java | package org.ohdsi.webapi.cohortdefinition;
import org.ohdsi.circe.cohortdefinition.CohortExpression;
import org.ohdsi.webapi.source.Source;
public class CohortGenerationRequest {
private CohortExpression expression;
private Source source;
private String sessionId;
private String targetSchema;
private Integer targetId;
public CohortGenerationRequest(CohortExpression expression, Source source, String sessionId, Integer targetId,
String targetSchema) {
this.expression = expression;
this.source = source;
this.sessionId = sessionId;
this.targetId = targetId;
this.targetSchema = targetSchema;
}
public CohortExpression getExpression() {
return expression;
}
public Source getSource() {
return source;
}
public String getSessionId() {
return sessionId;
}
public String getTargetSchema() {
return targetSchema;
}
public Integer getTargetId() {
return targetId;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationUtils.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationUtils.java | package org.ohdsi.webapi.cohortdefinition;
import org.apache.commons.lang3.StringUtils;
import org.ohdsi.circe.cohortdefinition.CohortExpressionQueryBuilder;
import org.ohdsi.circe.cohortdefinition.InclusionRule;
import org.ohdsi.sql.SqlRender;
import org.ohdsi.sql.SqlSplit;
import org.ohdsi.sql.SqlTranslate;
import org.ohdsi.webapi.source.Source;
import org.ohdsi.webapi.util.SourceUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import java.util.Arrays;
import java.util.List;
import static org.ohdsi.webapi.Constants.Params.TARGET_DATABASE_SCHEMA;
import static org.ohdsi.webapi.Constants.Params.DESIGN_HASH;
import static org.ohdsi.webapi.Constants.Tables.COHORT_CACHE;
import static org.ohdsi.webapi.Constants.Tables.COHORT_CENSOR_STATS_CACHE;
import static org.ohdsi.webapi.Constants.Tables.COHORT_INCLUSION_RESULT_CACHE;
import static org.ohdsi.webapi.Constants.Tables.COHORT_INCLUSION_STATS_CACHE;
import static org.ohdsi.webapi.Constants.Tables.COHORT_SUMMARY_STATS_CACHE;
public class CohortGenerationUtils {
public static void insertInclusionRules(CohortDefinition cohortDef, Source source, int designHash,
String targetSchema, String sessionId, JdbcTemplate jdbcTemplate) {
final String oracleTempSchema = SourceUtils.getTempQualifier(source);
String deleteSql = String.format("DELETE FROM %s.cohort_inclusion WHERE cohort_definition_id = %d;", targetSchema, cohortDef.getId());
String translatedDeleteSql = SqlTranslate.translateSql(deleteSql, source.getSourceDialect(), sessionId, oracleTempSchema);
Arrays.stream(SqlSplit.splitSql(translatedDeleteSql)).forEach(jdbcTemplate::execute);
String insertSql = StringUtils.replace("INSERT INTO @target_schema.cohort_inclusion (cohort_definition_id, design_hash, rule_sequence, name, description) VALUES (?,?,?,?,?)", "@target_schema", targetSchema);
String translatedInsertSql = SqlTranslate.translateSql(insertSql, source.getSourceDialect(), sessionId, oracleTempSchema);
List<InclusionRule> inclusionRules = cohortDef.getExpression().inclusionRules;
for (int i = 0; i< inclusionRules.size(); i++)
{
InclusionRule r = inclusionRules.get(i);
jdbcTemplate.update(translatedInsertSql, new Object[] { cohortDef.getId(), designHash, i, r.name, r.description});
}
}
public static String[] buildGenerationSql(CohortGenerationRequest request) {
Source source = request.getSource();
String cdmSchema = SourceUtils.getCdmQualifier(source);
String vocabSchema = SourceUtils.getVocabQualifierOrNull(source);
CohortExpressionQueryBuilder expressionQueryBuilder = new CohortExpressionQueryBuilder();
StringBuilder sqlBuilder = new StringBuilder();
CohortExpressionQueryBuilder.BuildExpressionQueryOptions options = new CohortExpressionQueryBuilder.BuildExpressionQueryOptions();
options.cohortIdFieldName = DESIGN_HASH;
options.cohortId = request.getTargetId();
options.cdmSchema = cdmSchema;
options.vocabularySchema = vocabSchema;
options.generateStats = true; // always generate with stats
final String oracleTempSchema = SourceUtils.getTempQualifier(source);
String expressionSql = expressionQueryBuilder.buildExpressionQuery(request.getExpression(), options);
expressionSql = SqlRender.renderSql(
expressionSql,
new String[] {"target_cohort_table",
"results_database_schema.cohort_inclusion_result",
"results_database_schema.cohort_inclusion_stats",
"results_database_schema.cohort_summary_stats",
"results_database_schema.cohort_censor_stats",
"results_database_schema.cohort_inclusion"
},
new String[] {
COHORT_CACHE,
"@target_database_schema." + COHORT_INCLUSION_RESULT_CACHE,
"@target_database_schema." + COHORT_INCLUSION_STATS_CACHE,
"@target_database_schema." + COHORT_SUMMARY_STATS_CACHE,
"@target_database_schema." + COHORT_CENSOR_STATS_CACHE,
"@target_database_schema.cohort_inclusion"
}
);
sqlBuilder.append(expressionSql);
String renderedSql = SqlRender.renderSql(
sqlBuilder.toString(),
new String[] {TARGET_DATABASE_SCHEMA},
new String[]{request.getTargetSchema()}
);
String translatedSql = SqlTranslate.translateSql(renderedSql, source.getSourceDialect(), request.getSessionId(), oracleTempSchema);
return SqlSplit.splitSql(translatedSql);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationInfo.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationInfo.java | /*
* Copyright 2015 Observational Health Data Sciences and Informatics [OHDSI.org].
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.cohortdefinition;
import org.ohdsi.webapi.GenerationStatus;
import org.ohdsi.webapi.IExecutionInfo;
import org.ohdsi.webapi.shiro.Entities.UserEntity;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MapsId;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
*
* @author Chris Knoll <cknoll@ohdsi.org>
*/
@Entity(name = "CohortGenerationInfo")
@Table(name="cohort_generation_info")
public class CohortGenerationInfo implements Serializable, IExecutionInfo {
private static final long serialVersionUID = 1L;
public CohortGenerationInfo()
{
}
public CohortGenerationInfo(CohortDefinition definition, Integer sourceId)
{
this.id = new CohortGenerationInfoId(definition.getId(), sourceId);
this.cohortDefinition = definition;
}
@EmbeddedId
private CohortGenerationInfoId id;
@ManyToOne
@MapsId("cohortDefinitionId")
@JoinColumn(name="id", referencedColumnName="id")
private CohortDefinition cohortDefinition;
@Column(name="start_time")
private Date startTime;
@Column(name="execution_duration")
private Integer executionDuration;
@Column(name="status")
private GenerationStatus status;
@Column(name="is_valid")
private boolean isValid;
@Column(name = "is_canceled")
private boolean isCanceled;
@Column(name="fail_message")
private String failMessage;
@Column(name="person_count")
private Long personCount;
@Column(name="record_count")
private Long recordCount;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "created_by_id")
private UserEntity createdBy;
@Column(name = "cc_generate_id")
private Long ccGenerateId;
// If true, then demographic has been selected.
@Column(name = "is_demographic")
private boolean isDemographic;
public boolean isDemographic() {
return isDemographic;
}
public void setIsDemographic(boolean isDemographic) {
this.isDemographic = isDemographic;
}
public CohortGenerationInfoId getId() {
return id;
}
public Date getStartTime() {
return startTime;
}
public CohortGenerationInfo setStartTime(Date startTime) {
this.startTime = startTime;
return this;
}
public Integer getExecutionDuration() {
return executionDuration;
}
public CohortGenerationInfo setExecutionDuration(Integer executionDuration) {
this.executionDuration = executionDuration;
return this;
}
public GenerationStatus getStatus() {
return status;
}
@Override
public boolean getIsValid() {
return isIsValid();
}
@Override
public String getMessage() {
return getFailMessage();
}
public CohortGenerationInfo setStatus(GenerationStatus status) {
this.status = status;
return this;
}
public boolean isIsValid() {
return isValid;
}
public CohortGenerationInfo setIsValid(boolean isValid) {
this.isValid = isValid;
return this;
}
@Override
public boolean getIsCanceled() {
return isCanceled();
}
public boolean isCanceled() {
return isCanceled;
}
public void setCanceled(boolean canceled) {
isCanceled = canceled;
}
@Override
public IExecutionInfo setMessage(String message) {
return setFailMessage(message);
}
public String getFailMessage() {
return failMessage;
}
public CohortGenerationInfo setFailMessage(String failMessage) {
this.failMessage = failMessage;
return this;
}
public Long getPersonCount() {
return personCount;
}
public CohortGenerationInfo setPersonCount(Long personCount) {
this.personCount = personCount;
return this;
}
public Long getRecordCount() {
return recordCount;
}
public CohortGenerationInfo setRecordCount(Long recordCount) {
this.recordCount = recordCount;
return this;
}
public void setCreatedBy(UserEntity createdBy) {
this.createdBy = createdBy;
}
public UserEntity getCreatedBy() {
return createdBy;
}
public Long getCcGenerateId() {
return ccGenerateId;
}
public void setCcGenerateId(Long ccGenerateId) {
this.ccGenerateId = ccGenerateId;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortDefinitionDetailsRepository.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CohortDefinitionDetailsRepository.java | package org.ohdsi.webapi.cohortdefinition;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
public interface CohortDefinitionDetailsRepository extends JpaRepository<CohortDefinitionDetails, Long> {
List<CohortDefinitionDetails> findByHashCode(Integer hashCode);
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationInfoRepository.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationInfoRepository.java | package org.ohdsi.webapi.cohortdefinition;
import org.ohdsi.webapi.GenerationStatus;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
public interface CohortGenerationInfoRepository extends CrudRepository<CohortGenerationInfo, CohortGenerationInfoId> {
List<CohortGenerationInfo> findByStatus(GenerationStatus status);
List<CohortGenerationInfo> findByStatusIn(List<GenerationStatus> statuses);
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CleanupCohortTasklet.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CleanupCohortTasklet.java | /*
* Copyright 2018 cknoll1.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.cohortdefinition;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.ohdsi.circe.helper.ResourceHelper;
import org.ohdsi.sql.SqlRender;
import org.ohdsi.sql.SqlTranslate;
import org.ohdsi.webapi.source.Source;
import org.ohdsi.webapi.source.SourceDaimon;
import org.ohdsi.webapi.source.SourceRepository;
import org.ohdsi.webapi.util.SessionUtils;
import org.ohdsi.webapi.util.SourceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
/**
*
* @author cknoll1
*/
public class CleanupCohortTasklet implements Tasklet {
private static final Logger log = LoggerFactory.getLogger(CleanupCohortTasklet.class);
private final TransactionTemplate transactionTemplate;
private final SourceRepository sourceRepository;
private final String CLEANUP_TEMPLATE = ResourceHelper.GetResourceAsString("/resources/cohortdefinition/sql/cleanupResults.sql");
public CleanupCohortTasklet(final TransactionTemplate transactionTemplate,
final SourceRepository sourceRepository) {
this.transactionTemplate = transactionTemplate;
this.sourceRepository = sourceRepository;
}
private JdbcTemplate getSourceJdbcTemplate(Source source) {
DriverManagerDataSource dataSource = new DriverManagerDataSource(source.getSourceConnection());
JdbcTemplate template = new JdbcTemplate(dataSource);
return template;
}
private Integer doTask(ChunkContext chunkContext) {
int sourcesUpdated = 0;
Map<String, Object> jobParams = chunkContext.getStepContext().getJobParameters();
Integer cohortId = Integer.valueOf(jobParams.get("cohort_definition_id").toString());
String sessionId = SessionUtils.sessionId();
List<Source> resultsSources = StreamSupport.stream(this.sourceRepository.findAll().spliterator(), false)
.filter(source->source.getDaimons().stream().filter(daimon->daimon.getDaimonType() == SourceDaimon.DaimonType.Results).findAny().isPresent())
.collect(Collectors.toList());
for (Source source : resultsSources) {
try {
String resultSchema = source.getTableQualifier(SourceDaimon.DaimonType.Results);
String deleteSql = SqlRender.renderSql(CLEANUP_TEMPLATE, new String[]{"results_database_schema", "cohort_definition_id"}, new String[]{resultSchema, cohortId.toString()});
deleteSql = SqlTranslate.translateSql(deleteSql, source.getSourceDialect(), sessionId, SourceUtils.getTempQualifier(source));
getSourceJdbcTemplate(source).batchUpdate(deleteSql.split(";")); // use batch update since SQL translation may produce multiple statements
sourcesUpdated++;
} catch (Exception e) {
log.error("Error deleting results for cohort: {}, cause: {}", cohortId, e.getMessage());
}
}
return sourcesUpdated;
}
@Override
public RepeatStatus execute(final StepContribution contribution, final ChunkContext chunkContext) throws Exception {
final Integer ret = this.transactionTemplate.execute(new TransactionCallback<Integer>() {
@Override
public Integer doInTransaction(final TransactionStatus status) {
return doTask(chunkContext);
}
});
return RepeatStatus.FINISHED;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortDefinition.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CohortDefinition.java | /*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.cohortdefinition;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.NamedSubgraph;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.ohdsi.analysis.Cohort;
import org.ohdsi.circe.cohortdefinition.CohortExpression;
import org.ohdsi.webapi.cohortanalysis.CohortAnalysisGenerationInfo;
import org.ohdsi.webapi.cohortcharacterization.domain.CohortCharacterizationEntity;
import org.ohdsi.webapi.model.CommonEntity;
import org.ohdsi.webapi.model.CommonEntityExt;
import org.ohdsi.webapi.tag.domain.Tag;
/**
* JPA Entity for Cohort Definitions
* @author cknoll1
*/
@Entity(name = "CohortDefinition")
@Table(name="cohort_definition")
@NamedEntityGraph(
name = "CohortDefinition.withDetail",
attributeNodes = { @NamedAttributeNode(value = "details", subgraph = "detailsGraph") },
subgraphs = {@NamedSubgraph(name = "detailsGraph", type = CohortDefinitionDetails.class, attributeNodes = { @NamedAttributeNode(value="expression")})}
)
public class CohortDefinition extends CommonEntityExt<Integer> implements Serializable, Cohort{
private static final long serialVersionUID = 1L;
@Id
@GenericGenerator(
name = "cohort_definition_generator",
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
parameters = {
@Parameter(name = "sequence_name", value = "cohort_definition_sequence"),
@Parameter(name = "increment_size", value = "1")
}
)
@GeneratedValue(generator = "cohort_definition_generator")
@Access(AccessType.PROPERTY)
private Integer id;
private String name;
private String description;
@Enumerated(EnumType.STRING)
@Column(name="expression_type")
private ExpressionType expressionType;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, optional = false, orphanRemoval = true, mappedBy="definition")
@JoinColumn(name="id")
private CohortDefinitionDetails details;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "cohortDefinition")
private Set<CohortGenerationInfo> generationInfoList;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "cohortDefinition")
private Set<CohortAnalysisGenerationInfo> cohortAnalysisGenerationInfoList = new HashSet<>();
@ManyToMany(targetEntity = CohortCharacterizationEntity.class, fetch = FetchType.LAZY)
@JoinTable(name = "cc_cohort",
joinColumns = @JoinColumn(name = "cohort_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "cohort_characterization_id", referencedColumnName = "id"))
private List<CohortCharacterizationEntity> cohortCharacterizations = new ArrayList<>();
@ManyToMany(targetEntity = Tag.class, fetch = FetchType.LAZY)
@JoinTable(name = "cohort_tag",
joinColumns = @JoinColumn(name = "asset_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "tag_id", referencedColumnName = "id"))
private Set<Tag> tags;
@Override
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public CohortDefinition setName(String name) {
this.name = name;
return this;
}
public String getDescription() {
return description;
}
public CohortDefinition setDescription(String description) {
this.description = description;
return this;
}
public ExpressionType getExpressionType() {
return expressionType;
}
public CohortDefinition setExpressionType(ExpressionType expressionType) {
this.expressionType = expressionType;
return this;
}
public CohortDefinitionDetails getDetails() {
return this.details;
}
public CohortDefinition setDetails(CohortDefinitionDetails details) {
this.details = details;
return this;
}
public Set<CohortGenerationInfo> getGenerationInfoList() {
return this.generationInfoList;
}
public CohortDefinition setGenerationInfoList(Set<CohortGenerationInfo> list) {
this.generationInfoList = list;
return this;
}
@Override
public boolean equals(final Object o) {
if (this == o) return true;
if (!(o instanceof CohortDefinition)) return false;
final CohortDefinition that = (CohortDefinition) o;
return Objects.equals(getId(), that.getId());
}
@Override
public int hashCode() {
return Objects.hash(getId());
}
public Set<CohortAnalysisGenerationInfo> getCohortAnalysisGenerationInfoList() {
return cohortAnalysisGenerationInfoList;
}
public void setCohortAnalysisGenerationInfoList(Set<CohortAnalysisGenerationInfo> cohortAnalysisGenerationInfoList) {
this.cohortAnalysisGenerationInfoList = cohortAnalysisGenerationInfoList;
}
@Override
public CohortExpression getExpression() {
return details != null ? details.getExpressionObject() : null;
}
public List<CohortCharacterizationEntity> getCohortCharacterizations() {
return cohortCharacterizations;
}
public void setCohortCharacterizations(final List<CohortCharacterizationEntity> cohortCharacterizations) {
this.cohortCharacterizations = cohortCharacterizations;
}
@Override
public Set<Tag> getTags() {
return tags;
}
@Override
public void setTags(Set<Tag> tags) {
this.tags = tags;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortDefinitionDetails.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CohortDefinitionDetails.java | /*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.cohortdefinition;
import java.io.Serializable;
import javax.persistence.*;
import com.fasterxml.jackson.core.type.TypeReference;
import org.hibernate.annotations.Type;
import org.ohdsi.analysis.Utils;
import org.ohdsi.circe.cohortdefinition.CohortExpression;
/**
*
* Stores the LOB/CLOB portion of the cohort definition expression.
*/
@Entity(name = "CohortDefinitionDetails")
@Table(name="cohort_definition_details")
public class CohortDefinitionDetails implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Integer id;
@MapsId
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name="id")
private CohortDefinition definition;
@Lob
@Type(type = "org.hibernate.type.TextType")
private String expression;
@Column(name = "hash_code")
private Integer hashCode;
@PrePersist
@PreUpdate
public void updateHashCode() {
this.setHashCode(calculateHashCode());
}
public Integer calculateHashCode() {
return getStandardizedExpression().hashCode();
}
public CohortExpression getExpressionObject() {
return (getExpression() != null) ? Utils.deserialize(getExpression(), new TypeReference<CohortExpression>() {}) : null;
}
public String getExpression() {
return expression;
}
public String getStandardizedExpression() {
return Utils.serialize(getExpressionObject());
}
public CohortDefinitionDetails setExpression(String expression) {
this.expression = expression;
return this;
}
public CohortDefinition getCohortDefinition() {
return this.definition;
}
public CohortDefinitionDetails setCohortDefinition(CohortDefinition definition) {
this.definition = definition;
return this;
}
public Integer getHashCode() {
return hashCode;
}
private void setHashCode(final Integer hashCode) {
this.hashCode = hashCode;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortDefinitionRepository.java | src/main/java/org/ohdsi/webapi/cohortdefinition/CohortDefinitionRepository.java | /*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.cohortdefinition;
import java.util.List;
import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
/**
*
* @author cknoll1
*/
public interface CohortDefinitionRepository extends CrudRepository<CohortDefinition, Integer> {
Page<CohortDefinition> findAll(Pageable pageable);
// Bug in hibernate, findById should use @EntityGraph, but details are not being fetched. Workaround: mark details Fetch.EAGER,
// but means findAll() will eager load definitions (what the @EntityGraph was supposed to solve)
@EntityGraph(value = "CohortDefinition.withDetail", type = EntityGraph.EntityGraphType.LOAD)
@Query("select cd from CohortDefinition cd LEFT JOIN FETCH cd.createdBy LEFT JOIN FETCH cd.modifiedBy where cd.id = ?1")
CohortDefinition findOneWithDetail(Integer id);
@Query("select cd from CohortDefinition AS cd LEFT JOIN FETCH cd.createdBy LEFT JOIN FETCH cd.modifiedBy")
List<CohortDefinition> list();
@Query("select count(cd) from CohortDefinition AS cd WHERE cd.name = :name and cd.id <> :id")
int getCountCDefWithSameName(@Param("id") Integer id, @Param("name") String name);
@Query("SELECT cd FROM CohortDefinition cd WHERE cd.name LIKE ?1 ESCAPE '\\'")
List<CohortDefinition> findAllByNameStartsWith(String pattern);
Optional<CohortDefinition> findByName(String name);
@Query("SELECT DISTINCT cd FROM CohortDefinition cd JOIN FETCH cd.tags t WHERE lower(t.name) in :tagNames")
List<CohortDefinition> findByTags(@Param("tagNames") List<String> tagNames);
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/GenerationJobExecutionListener.java | src/main/java/org/ohdsi/webapi/cohortdefinition/GenerationJobExecutionListener.java | /*
* Copyright 2017 cknoll1.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.cohortdefinition;
import org.apache.commons.lang3.StringUtils;
import org.ohdsi.sql.SqlRender;
import org.ohdsi.sql.SqlTranslate;
import org.ohdsi.webapi.Constants;
import org.ohdsi.webapi.GenerationStatus;
import org.ohdsi.webapi.source.Source;
import org.ohdsi.webapi.source.SourceService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.batch.core.JobParameters;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.transaction.support.TransactionTemplate;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
import static org.ohdsi.webapi.Constants.Params.TARGET_DATABASE_SCHEMA;
import org.springframework.batch.core.ExitStatus;
/**
* @author cknoll1
*/
public class GenerationJobExecutionListener implements JobExecutionListener {
private static final Logger log = LoggerFactory.getLogger(GenerationJobExecutionListener.class);
private final SourceService sourceService;
private final CohortDefinitionRepository cohortDefinitionRepository;
private final TransactionTemplate transactionTemplate;
private final JdbcTemplate sourceTemplate;
public GenerationJobExecutionListener(SourceService sourceService,
CohortDefinitionRepository cohortDefinitionRepository,
TransactionTemplate transactionTemplate,
JdbcTemplate sourceTemplate) {
this.sourceService = sourceService;
this.cohortDefinitionRepository = cohortDefinitionRepository;
this.transactionTemplate = transactionTemplate;
this.sourceTemplate = sourceTemplate;
}
private CohortGenerationInfo findBySourceId(CohortDefinition df, Integer sourceId) {
return df.getGenerationInfoList().stream()
.filter(info -> info.getId().getSourceId().equals(sourceId))
.findFirst()
.orElseThrow(() -> new IllegalStateException(String.format("Cannot find cohortGenerationInfo for cohortDefinition[{}] sourceId[%s]", df.getId(), sourceId)));
}
@Override
public void afterJob(JobExecution je) {
JobParameters jobParams = je.getJobParameters();
Integer defId = Integer.valueOf(jobParams.getString("cohort_definition_id"));
Integer sourceId = Integer.valueOf(jobParams.getString("source_id"));
String cohortTable = jobParams.getString(TARGET_DATABASE_SCHEMA) + ".cohort";
DefaultTransactionDefinition completeTx = new DefaultTransactionDefinition();
completeTx.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
TransactionStatus completeStatus = this.transactionTemplate.getTransactionManager().getTransaction(completeTx);
try {
Source source = sourceService.findBySourceId(sourceId);
CohortDefinition df = this.cohortDefinitionRepository.findOne(defId);
CohortGenerationInfo info = findBySourceId(df, sourceId);
setExecutionDurationIfPossible(je, info);
info.setStatus(GenerationStatus.COMPLETE);
info.setCcGenerateId(je.getId());
if (je.getStatus() == BatchStatus.FAILED || je.getStatus() == BatchStatus.STOPPED) {
info.setIsValid(false);
info.setRecordCount(null);
info.setPersonCount(null);
info.setCanceled(je.getStepExecutions().stream().anyMatch(se -> Objects.equals(Constants.CANCELED, se.getExitStatus().getExitCode())));
info.setFailMessage(StringUtils.abbreviateMiddle(je.getAllFailureExceptions().get(0).getMessage(), "... [truncated] ...", 2000));
} else {
info.setIsValid(true);
info.setFailMessage(null);
// query summary results from source
String statsQuery = "SELECT count(distinct subject_id) as person_count, count(*) as record_count from @cohort_table where cohort_definition_id = @cohort_definition_id";
String statsSql = SqlTranslate.translateSql(statsQuery, source.getSourceDialect(), null, null);
String renderedSql = SqlRender.renderSql(statsSql, new String[]{"cohort_table", "cohort_definition_id"}, new String[]{cohortTable, defId.toString()});
Map<String, Object> stats = this.sourceTemplate.queryForMap(renderedSql);
info.setPersonCount(Long.parseLong(stats.get("person_count").toString()));
info.setRecordCount(Long.parseLong(stats.get("record_count").toString()));
}
this.cohortDefinitionRepository.save(df);
this.transactionTemplate.getTransactionManager().commit(completeStatus);
} catch (Exception e) {
this.transactionTemplate.getTransactionManager().rollback(completeStatus);
log.error(e.getMessage());
je.addFailureException(e);
je.setExitStatus(new ExitStatus("FAILED", "Could not complete cohort generation job"));
je.setStatus(BatchStatus.FAILED);
}
}
private void setExecutionDurationIfPossible(JobExecution je, CohortGenerationInfo info) {
if (Objects.isNull(je.getEndTime()) || Objects.isNull(je.getStartTime())) {
log.error("Cannot set duration time for cohortGenerationInfo[{}]. startData[{}] and endData[{}] cannot be empty.", info.getId(), je.getStartTime(), je.getEndTime());
return;
}
info.setExecutionDuration((int) (je.getEndTime().getTime() - je.getStartTime().getTime()));
}
@Override
public void beforeJob(JobExecution je) {
Date startTime = Calendar.getInstance().getTime();
JobParameters jobParams = je.getJobParameters();
Integer defId = Integer.valueOf(jobParams.getString("cohort_definition_id"));
Integer sourceId = Integer.valueOf(jobParams.getString("source_id"));
DefaultTransactionDefinition initTx = new DefaultTransactionDefinition();
initTx.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
TransactionStatus initStatus = this.transactionTemplate.getTransactionManager().getTransaction(initTx);
try {
CohortDefinition df = this.cohortDefinitionRepository.findOne(defId);
CohortGenerationInfo info = findBySourceId(df, sourceId);
info.setIsValid(false);
info.setStartTime(startTime);
info.setStatus(GenerationStatus.RUNNING);
this.cohortDefinitionRepository.save(df);
this.transactionTemplate.getTransactionManager().commit(initStatus);
} catch (Exception e) {
this.transactionTemplate.getTransactionManager().rollback(initStatus);
log.error(e.getMessage());
je.addFailureException(e);
je.setExitStatus(new ExitStatus("FAILED", "Could not start cohort generation job"));
je.setStatus(BatchStatus.FAILED);
}
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortDTO.java | src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortDTO.java | package org.ohdsi.webapi.cohortdefinition.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.ohdsi.analysis.Cohort;
import org.ohdsi.circe.cohortdefinition.CohortExpression;
import org.ohdsi.webapi.cohortdefinition.ExpressionType;
public class CohortDTO extends CohortMetadataImplDTO implements Cohort{
private CohortExpression expression;
private ExpressionType expressionType;
@JsonSerialize(using = CohortDTOSerializer.class)
public CohortExpression getExpression() {
return expression;
}
public void setExpression(final CohortExpression expression) {
this.expression = expression;
}
public ExpressionType getExpressionType() {
return expressionType;
}
public void setExpressionType(final ExpressionType expressionType) {
this.expressionType = expressionType;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortVersionFullDTO.java | src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortVersionFullDTO.java | package org.ohdsi.webapi.cohortdefinition.dto;
import org.ohdsi.webapi.versioning.dto.VersionFullDTO;
public class CohortVersionFullDTO extends VersionFullDTO<CohortRawDTO> {
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortMetadataImplDTO.java | src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortMetadataImplDTO.java | package org.ohdsi.webapi.cohortdefinition.dto;
public class CohortMetadataImplDTO extends CohortMetadataDTO {
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortRawDTO.java | src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortRawDTO.java | /*
* Copyright 2019 cknoll1.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.cohortdefinition.dto;
import org.ohdsi.webapi.cohortdefinition.ExpressionType;
/**
*
* @author cknoll1
*/
public class CohortRawDTO extends CohortMetadataDTO {
private String expression;
private ExpressionType expressionType;
public String getExpression() {
return expression;
}
public void setExpression(final String expression) {
this.expression = expression;
}
public ExpressionType getExpressionType() {
return expressionType;
}
public void setExpressionType(final ExpressionType expressionType) {
this.expressionType = expressionType;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortDTOSerializer.java | src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortDTOSerializer.java | package org.ohdsi.webapi.cohortdefinition.dto;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.ohdsi.analysis.Utils;
import org.ohdsi.circe.cohortdefinition.CohortExpression;
import java.io.IOException;
public class CohortDTOSerializer extends JsonSerializer<CohortExpression> {
@Override
public void serialize(CohortExpression value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException {
gen.writeRawValue(Utils.serialize(value));
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortMetadataDTO.java | src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortMetadataDTO.java | package org.ohdsi.webapi.cohortdefinition.dto;
import org.ohdsi.webapi.cohortdefinition.CohortMetadataExt;
import org.ohdsi.webapi.service.dto.CommonEntityExtDTO;
public abstract class CohortMetadataDTO extends CommonEntityExtDTO implements CohortMetadataExt {
private Integer id;
private String name;
private String description;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
@Override
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortGenerationInfoDTO.java | src/main/java/org/ohdsi/webapi/cohortdefinition/dto/CohortGenerationInfoDTO.java | /*
* Copyright 2015 Observational Health Data Sciences and Informatics [OHDSI.org].
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.cohortdefinition.dto;
import org.ohdsi.webapi.GenerationStatus;
import org.ohdsi.webapi.cohortdefinition.CohortGenerationInfoId;
import org.ohdsi.webapi.user.dto.UserDTO;
import java.util.Date;
/**
* @author Chris Knoll <cknoll@ohdsi.org>
*/
public class CohortGenerationInfoDTO {
private CohortGenerationInfoId id;
private Date startTime;
private Integer executionDuration;
private GenerationStatus status;
private boolean isValid;
private boolean isCanceled;
private String failMessage;
private Long personCount;
private Long recordCount;
private UserDTO createdBy;
private Long ccGenerateId;
private boolean isDemographic;
public boolean getIsDemographic() {
return isDemographic;
}
public void setIsDemographic(boolean isDemographic) {
this.isDemographic = isDemographic;
}
public CohortGenerationInfoId getId() {
return id;
}
public void setId(CohortGenerationInfoId id) {
this.id = id;
}
public Date getStartTime() {
return startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Integer getExecutionDuration() {
return executionDuration;
}
public void setExecutionDuration(Integer executionDuration) {
this.executionDuration = executionDuration;
}
public GenerationStatus getStatus() {
return status;
}
public void setStatus(GenerationStatus status) {
this.status = status;
}
public boolean getIsValid() {
return isValid;
}
public void setIsValid(boolean isValid) {
this.isValid = isValid;
}
public boolean getIsCanceled() {
return isCanceled;
}
public void setIsCanceled(boolean isCanceled) {
this.isCanceled = isCanceled;
}
public String getFailMessage() {
return failMessage;
}
public void setFailMessage(String failMessage) {
this.failMessage = failMessage;
}
public Long getPersonCount() {
return personCount;
}
public void setPersonCount(Long personCount) {
this.personCount = personCount;
}
public Long getRecordCount() {
return recordCount;
}
public void setRecordCount(Long recordCount) {
this.recordCount = recordCount;
}
public UserDTO getCreatedBy() {
return createdBy;
}
public void setCreatedBy(UserDTO createdBy) {
this.createdBy = createdBy;
}
public Long getCcGenerateId() {
return ccGenerateId;
}
public void setCcGenerateId(Long ccGenerateId) {
this.ccGenerateId = ccGenerateId;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortGenerationInfoToCohortGenerationInfoDTOConverter.java | src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortGenerationInfoToCohortGenerationInfoDTOConverter.java | package org.ohdsi.webapi.cohortdefinition.converter;
import org.ohdsi.webapi.cohortdefinition.CohortGenerationInfo;
import org.ohdsi.webapi.cohortdefinition.dto.CohortGenerationInfoDTO;
import org.ohdsi.webapi.converter.BaseConversionServiceAwareConverter;
import org.ohdsi.webapi.user.dto.UserDTO;
import org.springframework.stereotype.Component;
@Component
public class CohortGenerationInfoToCohortGenerationInfoDTOConverter extends BaseConversionServiceAwareConverter<CohortGenerationInfo, CohortGenerationInfoDTO> {
@Override
public CohortGenerationInfoDTO convert(CohortGenerationInfo info) {
final CohortGenerationInfoDTO dto = new CohortGenerationInfoDTO();
dto.setIsCanceled(info.isCanceled());
dto.setCreatedBy(conversionService.convert(info.getCreatedBy(), UserDTO.class));
dto.setExecutionDuration(info.getExecutionDuration());
dto.setFailMessage(info.getFailMessage());
dto.setId(info.getId());
dto.setPersonCount(info.getPersonCount());
dto.setRecordCount(info.getRecordCount());
dto.setStartTime(info.getStartTime());
dto.setStatus(info.getStatus());
dto.setIsValid(info.isIsValid());
dto.setCcGenerateId(info.getCcGenerateId());
dto.setIsDemographic(info.isDemographic());
return dto;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortDefinitionToCohortDTOConverter.java | src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortDefinitionToCohortDTOConverter.java | package org.ohdsi.webapi.cohortdefinition.converter;
import org.ohdsi.circe.cohortdefinition.CohortExpression;
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;
import org.ohdsi.webapi.cohortdefinition.dto.CohortDTO;
import org.springframework.stereotype.Component;
@Component
public class CohortDefinitionToCohortDTOConverter extends BaseCohortDefinitionToCohortMetadataDTOConverter<CohortDTO> {
@Override
public void doConvert(CohortDefinition source, CohortDTO target) {
super.doConvert(source, target);
target.setExpressionType(source.getExpressionType());
if (source.getDetails() != null) {
CohortExpression expression = source.getDetails().getExpressionObject();
target.setExpression(expression);
}
}
@Override
protected CohortDTO createResultObject() {
return new CohortDTO();
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortDTOToCohortDefinitionConverter.java | src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortDTOToCohortDefinitionConverter.java | package org.ohdsi.webapi.cohortdefinition.converter;
import org.ohdsi.analysis.Cohort;
import org.ohdsi.analysis.Utils;
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;
import org.ohdsi.webapi.cohortdefinition.CohortDefinitionDetails;
import org.ohdsi.webapi.cohortdefinition.dto.CohortDTO;
import org.ohdsi.webapi.cohortdefinition.dto.CohortMetadataDTO;
import org.springframework.stereotype.Component;
@Component
public class CohortDTOToCohortDefinitionConverter extends BaseCohortDTOToCohortDefinitionConverter<CohortDTO> {
private String convertExpression(final Cohort source) {
return Utils.serialize(source.getExpression());
}
@Override
protected void doConvert(CohortDTO source, CohortDefinition target) {
super.doConvert(source, target);
if (source.getExpression() != null) {
final CohortDefinitionDetails details = new CohortDefinitionDetails();
final String expression = convertExpression(source);
details.setExpression(expression);
target.setDetails(details);
}
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/converter/BaseCohortDefinitionToCohortMetadataDTOConverter.java | src/main/java/org/ohdsi/webapi/cohortdefinition/converter/BaseCohortDefinitionToCohortMetadataDTOConverter.java | package org.ohdsi.webapi.cohortdefinition.converter;
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;
import org.ohdsi.webapi.cohortdefinition.dto.CohortMetadataDTO;
import org.ohdsi.webapi.service.converters.BaseCommonEntityExtToDTOExtConverter;
public abstract class BaseCohortDefinitionToCohortMetadataDTOConverter<T extends CohortMetadataDTO>
extends BaseCommonEntityExtToDTOExtConverter<CohortDefinition, T> {
@Override
public void doConvert(CohortDefinition def, T target) {
target.setId(def.getId());
target.setName(def.getName());
target.setDescription(def.getDescription());
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/converter/BaseCohortDTOToCohortDefinitionConverter.java | src/main/java/org/ohdsi/webapi/cohortdefinition/converter/BaseCohortDTOToCohortDefinitionConverter.java | package org.ohdsi.webapi.cohortdefinition.converter;
import org.apache.commons.lang3.StringUtils;
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;
import org.ohdsi.webapi.cohortdefinition.dto.CohortMetadataDTO;
import org.ohdsi.webapi.service.converters.BaseCommonDTOExtToEntityExtConverter;
public abstract class BaseCohortDTOToCohortDefinitionConverter<V extends CohortMetadataDTO> extends BaseCommonDTOExtToEntityExtConverter<V, CohortDefinition> {
@Override
protected void doConvert(V source, CohortDefinition target) {
target.setId(source.getId());
target.setName(StringUtils.trim(source.getName()));
target.setDescription(source.getDescription());
}
@Override
protected CohortDefinition createResultObject() {
return new CohortDefinition();
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortDefinitionToCohortMetadataDTOConverter.java | src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortDefinitionToCohortMetadataDTOConverter.java | package org.ohdsi.webapi.cohortdefinition.converter;
import org.ohdsi.webapi.cohortdefinition.dto.CohortMetadataDTO;
import org.ohdsi.webapi.cohortdefinition.dto.CohortMetadataImplDTO;
import org.springframework.stereotype.Component;
@Component
public class CohortDefinitionToCohortMetadataDTOConverter extends BaseCohortDefinitionToCohortMetadataDTOConverter<CohortMetadataImplDTO> {
@Override
protected CohortMetadataImplDTO createResultObject() {
return new CohortMetadataImplDTO();
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortDefinitionToCohortVersionConverter.java | src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortDefinitionToCohortVersionConverter.java | package org.ohdsi.webapi.cohortdefinition.converter;
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;
import org.ohdsi.webapi.cohortdefinition.CohortDefinitionDetails;
import org.ohdsi.webapi.cohortdefinition.CohortDefinitionRepository;
import org.ohdsi.webapi.converter.BaseConversionServiceAwareConverter;
import org.ohdsi.webapi.util.ExceptionUtils;
import org.ohdsi.webapi.versioning.domain.CohortVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class CohortDefinitionToCohortVersionConverter
extends BaseConversionServiceAwareConverter<CohortDefinition, CohortVersion> {
@Override
public CohortVersion convert(CohortDefinition source) {
CohortVersion target = new CohortVersion();
target.setAssetId(source.getId());
target.setDescription(source.getDescription());
target.setAssetJson(source.getDetails().getExpression());
return target;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortDefinitionToCohortRawDTOConverter.java | src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortDefinitionToCohortRawDTOConverter.java | package org.ohdsi.webapi.cohortdefinition.converter;
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;
import org.ohdsi.webapi.cohortdefinition.dto.CohortRawDTO;
import org.springframework.stereotype.Component;
@Component
public class CohortDefinitionToCohortRawDTOConverter extends BaseCohortDefinitionToCohortMetadataDTOConverter<CohortRawDTO> {
@Override
public void doConvert(CohortDefinition source, CohortRawDTO target) {
super.doConvert(source, target);
target.setExpressionType(source.getExpressionType());
if (source.getDetails() != null) {
target.setExpression(source.getDetails().getExpression());
}
}
@Override
protected CohortRawDTO createResultObject() {
return new CohortRawDTO();
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortMetadataDTOToCohortDefinitionConverter.java | src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortMetadataDTOToCohortDefinitionConverter.java | package org.ohdsi.webapi.cohortdefinition.converter;
import org.ohdsi.webapi.cohortdefinition.dto.CohortMetadataImplDTO;
import org.springframework.stereotype.Component;
@Component
public class CohortMetadataDTOToCohortDefinitionConverter extends BaseCohortDTOToCohortDefinitionConverter<CohortMetadataImplDTO> {
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortVersionToCohortVersionFullDTOConverter.java | src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortVersionToCohortVersionFullDTOConverter.java | package org.ohdsi.webapi.cohortdefinition.converter;
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;
import org.ohdsi.webapi.cohortdefinition.CohortDefinitionDetails;
import org.ohdsi.webapi.cohortdefinition.CohortDefinitionRepository;
import org.ohdsi.webapi.cohortdefinition.dto.CohortRawDTO;
import org.ohdsi.webapi.cohortdefinition.dto.CohortVersionFullDTO;
import org.ohdsi.webapi.converter.BaseConversionServiceAwareConverter;
import org.ohdsi.webapi.util.ExceptionUtils;
import org.ohdsi.webapi.versioning.domain.CohortVersion;
import org.ohdsi.webapi.versioning.dto.VersionDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class CohortVersionToCohortVersionFullDTOConverter
extends BaseConversionServiceAwareConverter<CohortVersion, CohortVersionFullDTO> {
@Autowired
private CohortDefinitionRepository cohortDefinitionRepository;
@Override
public CohortVersionFullDTO convert(CohortVersion source) {
CohortDefinition def = this.cohortDefinitionRepository.findOneWithDetail(source.getAssetId().intValue());
ExceptionUtils.throwNotFoundExceptionIfNull(def,
String.format("There is no cohort definition with id = %d.", source.getAssetId()));
CohortDefinitionDetails details = new CohortDefinitionDetails();
details.setExpression(source.getAssetJson());
CohortDefinition entity = new CohortDefinition();
entity.setId(def.getId());
entity.setTags(def.getTags());
entity.setName(def.getName());
entity.setExpressionType(def.getExpressionType());
entity.setDetails(details);
entity.setCohortAnalysisGenerationInfoList(def.getCohortAnalysisGenerationInfoList());
entity.setGenerationInfoList(def.getGenerationInfoList());
entity.setCreatedBy(def.getCreatedBy());
entity.setCreatedDate(def.getCreatedDate());
entity.setModifiedBy(def.getModifiedBy());
entity.setModifiedDate(def.getModifiedDate());
entity.setDescription(source.getDescription());
CohortVersionFullDTO target = new CohortVersionFullDTO();
target.setVersionDTO(conversionService.convert(source, VersionDTO.class));
target.setEntityDTO(conversionService.convert(entity, CohortRawDTO.class));
return target;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortRawDTOToCohortDTOConverter.java | src/main/java/org/ohdsi/webapi/cohortdefinition/converter/CohortRawDTOToCohortDTOConverter.java | package org.ohdsi.webapi.cohortdefinition.converter;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.C;
import org.ohdsi.analysis.Utils;
import org.ohdsi.circe.cohortdefinition.CohortExpression;
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;
import org.ohdsi.webapi.cohortdefinition.dto.CohortDTO;
import org.ohdsi.webapi.cohortdefinition.dto.CohortMetadataDTO;
import org.ohdsi.webapi.cohortdefinition.dto.CohortRawDTO;
import org.ohdsi.webapi.converter.BaseConversionServiceAwareConverter;
import org.ohdsi.webapi.service.converters.BaseCommonDTOExtToEntityExtConverter;
import org.springframework.stereotype.Component;
import java.util.Objects;
@Component
public class CohortRawDTOToCohortDTOConverter extends BaseConversionServiceAwareConverter<CohortRawDTO, CohortDTO> {
@Override
public CohortDTO convert(CohortRawDTO source) {
CohortDTO target = new CohortDTO();
target.setDescription(source.getDescription());
target.setName((source.getName()));
target.setId(source.getId());
CohortExpression expression = Objects.nonNull(source.getExpression()) ?
Utils.deserialize(source.getExpression(), new TypeReference<CohortExpression>() {}) : null;
target.setExpression(expression);
target.setExpressionType(source.getExpressionType());
target.setCreatedBy(source.getCreatedBy());
target.setCreatedDate(source.getCreatedDate());
target.setModifiedBy(source.getModifiedBy());
target.setModifiedDate(source.getModifiedDate());
target.setTags(source.getTags());
return target;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/cohortdefinition/event/CohortDefinitionChangedEvent.java | src/main/java/org/ohdsi/webapi/cohortdefinition/event/CohortDefinitionChangedEvent.java | package org.ohdsi.webapi.cohortdefinition.event;
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;
public class CohortDefinitionChangedEvent {
private CohortDefinition cohortDefinition;
public CohortDefinitionChangedEvent(CohortDefinition cohortDefinition) {
this.cohortDefinition = cohortDefinition;
}
public CohortDefinition getCohortDefinition() {
return cohortDefinition;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/TagSecurityUtils.java | src/main/java/org/ohdsi/webapi/tag/TagSecurityUtils.java | package org.ohdsi.webapi.tag;
import org.apache.shiro.SecurityUtils;
import org.ohdsi.webapi.cohortcharacterization.domain.CohortCharacterizationEntity;
import org.ohdsi.webapi.cohortdefinition.CohortDefinition;
import org.ohdsi.webapi.conceptset.ConceptSet;
import org.ohdsi.webapi.ircalc.IncidenceRateAnalysis;
import org.ohdsi.webapi.model.CommonEntityExt;
import org.ohdsi.webapi.pathway.domain.PathwayAnalysisEntity;
import org.ohdsi.webapi.reusable.domain.Reusable;
import javax.ws.rs.BadRequestException;
public class TagSecurityUtils {
public static String COHORT_DEFINITION = "cohortdefinition";
public static String CONCEPT_SET = "conceptset";
public static String COHORT_CHARACTERIZATION = "cohort-characterization";
public static String INCIDENCE_RATE = "ir";
public static String PATHWAY_ANALYSIS = "pathway-analysis";
public static String REUSABLE = "reusable";
public static boolean canAssingProtectedTags() {
return checkPermission(COHORT_DEFINITION, "post") ||
checkPermission(CONCEPT_SET, "post") ||
checkPermission(COHORT_CHARACTERIZATION, "post") ||
checkPermission(INCIDENCE_RATE, "post") ||
checkPermission(PATHWAY_ANALYSIS, "post") ||
checkPermission(REUSABLE, "post");
}
public static boolean canUnassingProtectedTags() {
return checkPermission(COHORT_DEFINITION, "delete") ||
checkPermission(CONCEPT_SET, "delete") ||
checkPermission(COHORT_CHARACTERIZATION, "delete") ||
checkPermission(INCIDENCE_RATE, "delete") ||
checkPermission(PATHWAY_ANALYSIS, "delete") ||
checkPermission(REUSABLE, "delete");
}
public static boolean checkPermission(final String asset, final String method) {
if (asset == null) {
return false;
}
final String template;
switch (method) {
case "post":
template = "%s:*:protectedtag:post";
break;
case "delete":
template = "%s:*:protectedtag:*:delete";
break;
default:
throw new BadRequestException(String.format("Unsupported method: %s", method));
}
final String permission = String.format(template, asset);
return SecurityUtils.getSubject().isPermitted(permission);
}
public static String getAssetName(final CommonEntityExt<?> entity) {
if (entity instanceof ConceptSet) {
return TagSecurityUtils.CONCEPT_SET;
} else if (entity instanceof CohortDefinition) {
return TagSecurityUtils.COHORT_DEFINITION;
} else if (entity instanceof CohortCharacterizationEntity) {
return TagSecurityUtils.COHORT_CHARACTERIZATION;
} else if (entity instanceof IncidenceRateAnalysis) {
return TagSecurityUtils.INCIDENCE_RATE;
} else if (entity instanceof PathwayAnalysisEntity) {
return TagSecurityUtils.PATHWAY_ANALYSIS;
} else if (entity instanceof Reusable) {
return TagSecurityUtils.REUSABLE;
}
return null;
}
public static boolean canManageTags() {
return SecurityUtils.getSubject().isPermitted("tag:management");
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/TagService.java | src/main/java/org/ohdsi/webapi/tag/TagService.java | package org.ohdsi.webapi.tag;
import org.apache.shiro.SecurityUtils;
import org.glassfish.jersey.internal.util.Producer;
import org.ohdsi.webapi.service.AbstractDaoService;
import org.ohdsi.webapi.tag.domain.Tag;
import org.ohdsi.webapi.tag.domain.TagInfo;
import org.ohdsi.webapi.tag.domain.TagType;
import org.ohdsi.webapi.tag.dto.TagDTO;
import org.ohdsi.webapi.tag.dto.AssignmentPermissionsDTO;
import org.ohdsi.webapi.tag.repository.TagRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.ConversionService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Transactional
public class TagService extends AbstractDaoService {
private static final Logger logger = LoggerFactory.getLogger(TagService.class);
private final TagRepository tagRepository;
private final EntityManager entityManager;
private final ConversionService conversionService;
private final ArrayList<Producer<List<TagInfo>>> infoProducers;
@Autowired
public TagService(
TagRepository tagRepository,
EntityManager entityManager,
ConversionService conversionService) {
this.tagRepository = tagRepository;
this.entityManager = entityManager;
this.conversionService = conversionService;
this.infoProducers = new ArrayList<>();
this.infoProducers.add(tagRepository::findCohortTagInfo);
this.infoProducers.add(tagRepository::findCcTagInfo);
this.infoProducers.add(tagRepository::findConceptSetTagInfo);
this.infoProducers.add(tagRepository::findIrTagInfo);
this.infoProducers.add(tagRepository::findPathwayTagInfo);
this.infoProducers.add(tagRepository::findReusableTagInfo);
}
public TagDTO create(TagDTO dto) {
Tag tag = conversionService.convert(dto, Tag.class);
Tag saved = create(tag);
return conversionService.convert(saved, TagDTO.class);
}
public Tag create(Tag tag) {
tag.setType(TagType.CUSTOM);
List<Integer> groupIds = tag.getGroups().stream()
.map(Tag::getId)
.collect(Collectors.toList());
List<Tag> groups = findByIdIn(groupIds);
boolean allowCustom = groups.stream()
.filter(Tag::isAllowCustom)
.count() == groups.size();
if (this.getPermissionService().isSecurityEnabled() && !TagSecurityUtils.canManageTags() && !allowCustom) {
throw new IllegalArgumentException("Tag can be added only to groups that allows to do it");
}
tag.setGroups(new HashSet<>(groups));
tag.setCreatedBy(getCurrentUser());
tag.setCreatedDate(new Date());
return save(tag);
}
public Tag getById(Integer id) {
return tagRepository.findOne(id);
}
public TagDTO getDTOById(Integer id) {
Tag tag = tagRepository.findOne(id);
return conversionService.convert(tag, TagDTO.class);
}
public List<TagDTO> listInfoDTO(String namePart) {
return listInfo(namePart).stream()
.map(tag -> conversionService.convert(tag, TagDTO.class))
.collect(Collectors.toList());
}
public List<TagDTO> listInfoDTO() {
return listInfo().stream()
.map(tag -> conversionService.convert(tag, TagDTO.class))
.collect(Collectors.toList());
}
public List<Tag> listInfo(String namePart) {
return tagRepository.findAllTags(namePart);
}
public List<Tag> listInfo() {
return tagRepository.findAll();
}
public List<Tag> findByIdIn(List<Integer> ids) {
return tagRepository.findByIdIn(ids);
}
public TagDTO update(Integer id, TagDTO entity) {
Tag existing = tagRepository.findOne(id);
checkOwnerOrAdmin(existing.getCreatedBy());
Tag toUpdate = this.conversionService.convert(entity, Tag.class);
List<Integer> groupIds = toUpdate.getGroups().stream()
.map(Tag::getId)
.collect(Collectors.toList());
List<Tag> groups = findByIdIn(groupIds);
toUpdate.setGroups(new HashSet<>(groups));
toUpdate.setCreatedBy(existing.getCreatedBy());
toUpdate.setCreatedDate(existing.getCreatedDate());
toUpdate.setModifiedBy(getCurrentUser());
toUpdate.setModifiedDate(new Date());
Tag saved = save(toUpdate);
return conversionService.convert(saved, TagDTO.class);
}
public void delete(Integer id) {
Tag existing = tagRepository.findOne(id);
checkOwnerOrAdmin(existing.getCreatedBy());
tagRepository.delete(id);
}
private Tag save(Tag tag) {
tag = tagRepository.saveAndFlush(tag);
entityManager.refresh(tag);
return tagRepository.findOne(tag.getId());
}
@Transactional
@Scheduled(fixedDelayString = "${tag.refreshStat.period}")
public void refreshTagStatistics() {
logger.info("Starting tags statistics refreshing");
try {
// Getting tag statistics in one query with multiple join clauses
// will take significant amount of time
// So we'll get this information for each asset in series
Map<Integer, TagDTO> infoMap = new HashMap<>();
this.infoProducers.forEach(producer -> processTagInfo(producer, infoMap));
List<Tag> tags = tagRepository.findAll();
tags = tags.stream()
.peek(tag -> {
TagDTO info = infoMap.get(tag.getId());
if (Objects.nonNull(info)) {
tag.setCount(info.getCount());
}
})
.collect(Collectors.toList());
tagRepository.save(tags);
} catch (Exception e) {
logger.error("Cannot refresh tags statistics");
}
logger.info("Finishing tags statistics refreshing");
}
private void processTagInfo(Producer<List<TagInfo>> infoProducer,
Map<Integer, TagDTO> infoMap) {
List<TagInfo> tagInfos = infoProducer.call();
tagInfos.forEach(info -> {
int id = info.getId();
TagDTO dto = infoMap.get(id);
if (Objects.isNull(dto)) {
infoMap.put(id, new TagDTO());
dto = infoMap.get(id);
}
int count = dto.getCount() + info.getCount();
dto.setCount(count);
});
}
public List<Tag> findMandatoryTags() {
return tagRepository.findMandatoryTags();
}
public Set<Integer> getAllGroupsForTag(Integer id) {
Tag tag = getById(id);
Set<Integer> groupIds = new HashSet<>();
if (Objects.nonNull(tag)) {
groupIds.add(tag.getId());
findParentGroup(tag.getGroups(), groupIds);
}
return groupIds;
}
private void findParentGroup(Set<Tag> groups, Set<Integer> groupIds) {
groups.forEach(g -> {
groupIds.add(g.getId());
findParentGroup(g.getGroups(), groupIds);
});
}
public AssignmentPermissionsDTO getAssignmentPermissions() {
final AssignmentPermissionsDTO tagPermission = new AssignmentPermissionsDTO();
tagPermission.setAnyAssetMultiAssignPermitted(isAdmin());
tagPermission.setCanAssignProtectedTags(!isSecured() || TagSecurityUtils.canAssingProtectedTags());
tagPermission.setCanUnassignProtectedTags(!isSecured() || TagSecurityUtils.canUnassingProtectedTags());
return tagPermission;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/TagController.java | src/main/java/org/ohdsi/webapi/tag/TagController.java | package org.ohdsi.webapi.tag;
import org.apache.commons.lang3.StringUtils;
import org.ohdsi.webapi.tag.dto.TagDTO;
import org.ohdsi.webapi.tag.dto.TagGroupSubscriptionDTO;
import org.ohdsi.webapi.tag.dto.AssignmentPermissionsDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import java.util.Collections;
import java.util.List;
@Path("/tag")
@Controller
public class TagController {
private final TagService tagService;
private final TagGroupService tagGroupService;
@Autowired
public TagController(TagService pathwayService,
TagGroupService tagGroupService) {
this.tagService = pathwayService;
this.tagGroupService = tagGroupService;
}
/**
* Creates a tag.
*
* @param dto
* @return
*/
@POST
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public TagDTO create(final TagDTO dto) {
return tagService.create(dto);
}
/**
* Returns list of tags, which names contain a provided substring.
*
* @summary Search tags by name part
* @param namePart
* @return
*/
@GET
@Path("/search")
@Produces(MediaType.APPLICATION_JSON)
public List<TagDTO> search(@QueryParam("namePart") String namePart) {
if (StringUtils.isBlank(namePart)) {
return Collections.emptyList();
}
return tagService.listInfoDTO(namePart);
}
/**
* Returns list of all tags.
*
* @return
*/
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public List<TagDTO> list() {
return tagService.listInfoDTO();
}
/**
* Updates tag with ID={id}.
*
* @param id
* @param dto
* @return
*/
@PUT
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public TagDTO update(@PathParam("id") final Integer id, final TagDTO dto) {
return tagService.update(id, dto);
}
/**
* Return tag by ID.
*
* @param id
* @return
*/
@GET
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public TagDTO get(@PathParam("id") final Integer id) {
return tagService.getDTOById(id);
}
/**
* Deletes tag with ID={id}.
*
* @param id
*/
@DELETE
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public void delete(@PathParam("id") final Integer id) {
tagService.delete(id);
}
/**
* Assignes group of tags to groups of assets.
*
* @param dto
* @return
*/
@POST
@Path("/multiAssign")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public void assignGroup(final TagGroupSubscriptionDTO dto) {
tagGroupService.assignGroup(dto);
}
/**
* Unassignes group of tags from groups of assets.
*
* @param dto
* @return
*/
@POST
@Path("/multiUnassign")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public void unassignGroup(final TagGroupSubscriptionDTO dto) {
tagGroupService.unassignGroup(dto);
}
/**
* Tags assignment permissions for current user
*
* @return
*/
@GET
@Path("/assignmentPermissions")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public AssignmentPermissionsDTO assignmentPermissions() {
return tagService.getAssignmentPermissions();
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/TagGroupService.java | src/main/java/org/ohdsi/webapi/tag/TagGroupService.java | package org.ohdsi.webapi.tag;
import org.ohdsi.webapi.cohortcharacterization.CcService;
import org.ohdsi.webapi.pathway.PathwayService;
import org.ohdsi.webapi.reusable.ReusableService;
import org.ohdsi.webapi.service.*;
import org.ohdsi.webapi.tag.domain.HasTags;
import org.ohdsi.webapi.tag.dto.TagGroupSubscriptionDTO;
import org.ohdsi.webapi.tag.repository.TagRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.ws.rs.ForbiddenException;
import java.util.ArrayList;
import java.util.List;
@Service
@Transactional
public class TagGroupService extends AbstractDaoService {
private final TagRepository tagRepository;
private final PathwayService pathwayService;
private final CcService ccService;
private final CohortDefinitionService cohortDefinitionService;
private final ConceptSetService conceptSetService;
private final IRAnalysisResource irAnalysisService;
private final ReusableService reusableService;
@Autowired
public TagGroupService(
TagRepository tagRepository,
PathwayService pathwayService,
CcService ccService,
CohortDefinitionService cohortDefinitionService,
ConceptSetService conceptSetService,
IRAnalysisResource irAnalysisService,
ReusableService reusableService) {
this.tagRepository = tagRepository;
this.pathwayService = pathwayService;
this.ccService = ccService;
this.cohortDefinitionService = cohortDefinitionService;
this.conceptSetService = conceptSetService;
this.irAnalysisService = irAnalysisService;
this.reusableService = reusableService;
}
public void assignGroup(TagGroupSubscriptionDTO dto) {
tagRepository.findByIdIn(new ArrayList<>(dto.getTags()))
.forEach(tag -> {
assignGroup(ccService, dto.getAssets().getCharacterizations(), tag.getId());
assignGroup(pathwayService, dto.getAssets().getPathways(), tag.getId());
assignGroup(cohortDefinitionService, dto.getAssets().getCohorts(), tag.getId());
assignGroup(conceptSetService, dto.getAssets().getConceptSets(), tag.getId());
assignGroup(irAnalysisService, dto.getAssets().getIncidenceRates(), tag.getId());
assignGroup(reusableService, dto.getAssets().getReusables(), tag.getId());
});
}
public void unassignGroup(TagGroupSubscriptionDTO dto) {
tagRepository.findByIdIn(new ArrayList<>(dto.getTags()))
.forEach(tag -> {
unassignGroup(ccService, dto.getAssets().getCharacterizations(), tag.getId());
unassignGroup(pathwayService, dto.getAssets().getPathways(), tag.getId());
unassignGroup(cohortDefinitionService, dto.getAssets().getCohorts(), tag.getId());
unassignGroup(conceptSetService, dto.getAssets().getConceptSets(), tag.getId());
unassignGroup(irAnalysisService, dto.getAssets().getIncidenceRates(), tag.getId());
unassignGroup(reusableService, dto.getAssets().getReusables(), tag.getId());
});
}
private <T extends Number> void assignGroup(HasTags<T> service, List<T> assetIds, Integer tagId) {
assetIds.forEach(id -> {
try {
service.assignTag(id, tagId);
} catch (final ForbiddenException e) {
log.warn("Tag {} cannot be assigned to entity {} in service {} - forbidden", tagId, id, service.getClass().getName());
throw e;
}
});
}
private <T extends Number> void unassignGroup(HasTags<T> service, List<T> assetIds, Integer tagId) {
assetIds.forEach(id -> {
try {
service.unassignTag(id, tagId);
} catch(final ForbiddenException e) {
log.warn("Tag {} cannot be unassigned from entity {} in service {} - forbidden", tagId, id, service.getClass().getName());
}
});
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/dto/TagGroupSubscriptionDTO.java | src/main/java/org/ohdsi/webapi/tag/dto/TagGroupSubscriptionDTO.java | package org.ohdsi.webapi.tag.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashSet;
import java.util.Set;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TagGroupSubscriptionDTO {
@JsonProperty
private Set<Integer> tags = new HashSet<>();
@JsonProperty
private AssetGroup assets;
public Set<Integer> getTags() {
return tags;
}
public void setTags(Set<Integer> tags) {
this.tags = tags;
}
public AssetGroup getAssets() {
return assets;
}
public void setAssets(AssetGroup assets) {
this.assets = assets;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/dto/TagNameListRequestDTO.java | src/main/java/org/ohdsi/webapi/tag/dto/TagNameListRequestDTO.java | package org.ohdsi.webapi.tag.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TagNameListRequestDTO {
@JsonProperty
private List<String> names;
public List<String> getNames() {
return names;
}
public void setNames(List<String> names) {
this.names = names;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/dto/AssetGroup.java | src/main/java/org/ohdsi/webapi/tag/dto/AssetGroup.java | package org.ohdsi.webapi.tag.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.List;
public class AssetGroup {
@JsonProperty
private List<Integer> cohorts = new ArrayList<>();
@JsonProperty
private List<Integer> conceptSets = new ArrayList<>();
@JsonProperty
private List<Long> characterizations = new ArrayList<>();
@JsonProperty
private List<Integer> incidenceRates = new ArrayList<>();
@JsonProperty
private List<Integer> pathways = new ArrayList<>();
@JsonProperty
private List<Integer> reusables = new ArrayList<>();
public List<Integer> getCohorts() {
return cohorts;
}
public void setCohorts(List<Integer> cohorts) {
this.cohorts = cohorts;
}
public List<Integer> getConceptSets() {
return conceptSets;
}
public void setConceptSets(List<Integer> conceptSets) {
this.conceptSets = conceptSets;
}
public List<Long> getCharacterizations() {
return characterizations;
}
public void setCharacterizations(List<Long> characterizations) {
this.characterizations = characterizations;
}
public List<Integer> getIncidenceRates() {
return incidenceRates;
}
public void setIncidenceRates(List<Integer> incidenceRates) {
this.incidenceRates = incidenceRates;
}
public List<Integer> getPathways() {
return pathways;
}
public void setPathways(List<Integer> pathways) {
this.pathways = pathways;
}
public List<Integer> getReusables() {
return reusables;
}
public void setReusables(final List<Integer> reusables) {
this.reusables = reusables;
}
} | java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/dto/AssignmentPermissionsDTO.java | src/main/java/org/ohdsi/webapi/tag/dto/AssignmentPermissionsDTO.java | package org.ohdsi.webapi.tag.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AssignmentPermissionsDTO {
private boolean isAnyAssetMultiAssignPermitted;
private boolean canAssignProtectedTags;
private boolean canUnassignProtectedTags;
public boolean isCanAssignProtectedTags() {
return canAssignProtectedTags;
}
public void setCanAssignProtectedTags(final boolean canAssignProtectedTags) {
this.canAssignProtectedTags = canAssignProtectedTags;
}
public boolean isCanUnassignProtectedTags() {
return canUnassignProtectedTags;
}
public void setCanUnassignProtectedTags(final boolean canUnassignProtectedTags) {
this.canUnassignProtectedTags = canUnassignProtectedTags;
}
public boolean isAnyAssetMultiAssignPermitted() {
return isAnyAssetMultiAssignPermitted;
}
public void setAnyAssetMultiAssignPermitted(final boolean anyAssetMultiAssignPermitted) {
isAnyAssetMultiAssignPermitted = anyAssetMultiAssignPermitted;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/dto/TagDTO.java | src/main/java/org/ohdsi/webapi/tag/dto/TagDTO.java | package org.ohdsi.webapi.tag.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.ohdsi.webapi.service.dto.CommonEntityDTO;
import org.ohdsi.webapi.tag.domain.TagType;
import java.util.Objects;
import java.util.Set;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TagDTO extends CommonEntityDTO {
@JsonProperty
Integer id;
@JsonProperty
private Set<TagDTO> groups;
@JsonProperty
private String name;
@JsonProperty
private TagType type;
@JsonProperty
private int count;
@JsonProperty
private boolean showGroup;
@JsonProperty
private boolean multiSelection;
@JsonProperty
private boolean permissionProtected;
@JsonProperty
private String icon;
@JsonProperty
private String color;
@JsonProperty
private boolean mandatory;
@JsonProperty
private boolean allowCustom;
@JsonProperty
private String description;
@Override
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Set<TagDTO> getGroups() {
return groups;
}
public void setGroups(Set<TagDTO> groups) {
this.groups = groups;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
public TagType getType() {
return type;
}
public void setType(TagType type) {
this.type = type;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public boolean isShowGroup() {
return showGroup;
}
public void setShowGroup(boolean showGroup) {
this.showGroup = showGroup;
}
public boolean isMultiSelection() {
return multiSelection;
}
public void setMultiSelection(boolean multiSelection) {
this.multiSelection = multiSelection;
}
public boolean isPermissionProtected() {
return permissionProtected;
}
public void setPermissionProtected(boolean permissionProtected) {
this.permissionProtected = permissionProtected;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public boolean isMandatory() {
return mandatory;
}
public void setMandatory(boolean mandatory) {
this.mandatory = mandatory;
}
public boolean isAllowCustom() {
return allowCustom;
}
public void setAllowCustom(boolean allowCustom) {
this.allowCustom = allowCustom;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TagDTO tag = (TagDTO) o;
return name.equals(tag.name);
}
@Override
public int hashCode() {
return Objects.hash(name);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/domain/HasTags.java | src/main/java/org/ohdsi/webapi/tag/domain/HasTags.java | package org.ohdsi.webapi.tag.domain;
public interface HasTags<T extends Number> {
void assignTag(T id, int tagId);
void unassignTag(T id, int tagId);
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/domain/TagType.java | src/main/java/org/ohdsi/webapi/tag/domain/TagType.java | package org.ohdsi.webapi.tag.domain;
import java.util.Arrays;
public enum TagType {
SYSTEM(0), CUSTOM(1), PRIZM(2);
private final int value;
TagType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public static TagType fromValue(int value) {
return Arrays.stream(values())
.filter(t -> t.value == value)
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(String.format("Tag type (%s) cannot be found", value)));
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/domain/IrTag.java | src/main/java/org/ohdsi/webapi/tag/domain/IrTag.java | package org.ohdsi.webapi.tag.domain;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity(name = "IrTag")
@Table(name = "ir_tag")
public class IrTag {
@EmbeddedId
private AssetTagPK assetId;
@OneToOne(optional = false, targetEntity = Tag.class, fetch = FetchType.LAZY)
@JoinColumn(name = "tag_id", insertable = false, updatable = false)
private Tag tag;
public AssetTagPK getAssetId() {
return assetId;
}
public void setAssetId(AssetTagPK assetId) {
this.assetId = assetId;
}
public Tag getTag() {
return tag;
}
public void setTag(Tag tag) {
this.tag = tag;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/domain/TagInfo.java | src/main/java/org/ohdsi/webapi/tag/domain/TagInfo.java | package org.ohdsi.webapi.tag.domain;
public interface TagInfo {
int getId();
int getCount();
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/domain/CohortCharacterizationTag.java | src/main/java/org/ohdsi/webapi/tag/domain/CohortCharacterizationTag.java | package org.ohdsi.webapi.tag.domain;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity(name = "CohortCharacterizationTag")
@Table(name = "cohort_characterization_tag")
public class CohortCharacterizationTag {
@EmbeddedId
private AssetTagPK assetId;
@OneToOne(optional = false, targetEntity = Tag.class, fetch = FetchType.LAZY)
@JoinColumn(name = "tag_id", insertable = false, updatable = false)
private Tag tag;
public AssetTagPK getAssetId() {
return assetId;
}
public void setAssetId(AssetTagPK assetId) {
this.assetId = assetId;
}
public Tag getTag() {
return tag;
}
public void setTag(Tag tag) {
this.tag = tag;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/domain/ReusableTag.java | src/main/java/org/ohdsi/webapi/tag/domain/ReusableTag.java | package org.ohdsi.webapi.tag.domain;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity(name = "ReusableTag")
@Table(name = "reusable_tag")
public class ReusableTag {
@EmbeddedId
private AssetTagPK assetId;
@OneToOne(optional = false, targetEntity = Tag.class, fetch = FetchType.LAZY)
@JoinColumn(name = "tag_id", insertable = false, updatable = false)
private Tag tag;
public AssetTagPK getAssetId() {
return assetId;
}
public void setAssetId(AssetTagPK assetId) {
this.assetId = assetId;
}
public Tag getTag() {
return tag;
}
public void setTag(Tag tag) {
this.tag = tag;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/domain/ConceptSetTag.java | src/main/java/org/ohdsi/webapi/tag/domain/ConceptSetTag.java | package org.ohdsi.webapi.tag.domain;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity(name = "ConceptSetTag")
@Table(name = "concept_set_tag")
public class ConceptSetTag {
@EmbeddedId
private AssetTagPK assetId;
@OneToOne(optional = false, targetEntity = Tag.class, fetch = FetchType.LAZY)
@JoinColumn(name = "tag_id", insertable = false, updatable = false)
private Tag tag;
public AssetTagPK getAssetId() {
return assetId;
}
public void setAssetId(AssetTagPK assetId) {
this.assetId = assetId;
}
public Tag getTag() {
return tag;
}
public void setTag(Tag tag) {
this.tag = tag;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/domain/PathwayTag.java | src/main/java/org/ohdsi/webapi/tag/domain/PathwayTag.java | package org.ohdsi.webapi.tag.domain;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity(name = "PathwayTag")
@Table(name = "pathway_tag")
public class PathwayTag {
@EmbeddedId
private AssetTagPK assetId;
@OneToOne(optional = false, targetEntity = Tag.class, fetch = FetchType.LAZY)
@JoinColumn(name = "tag_id", insertable = false, updatable = false)
private Tag tag;
public AssetTagPK getAssetId() {
return assetId;
}
public void setAssetId(AssetTagPK assetId) {
this.assetId = assetId;
}
public Tag getTag() {
return tag;
}
public void setTag(Tag tag) {
this.tag = tag;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/domain/CohortTag.java | src/main/java/org/ohdsi/webapi/tag/domain/CohortTag.java | package org.ohdsi.webapi.tag.domain;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity(name = "CohortTag")
@Table(name = "cohort_tag")
public class CohortTag {
@EmbeddedId
private AssetTagPK assetId;
@OneToOne(optional = false, targetEntity = Tag.class, fetch = FetchType.LAZY)
@JoinColumn(name = "tag_id", insertable = false, updatable = false)
private Tag tag;
public AssetTagPK getAssetId() {
return assetId;
}
public void setAssetId(AssetTagPK assetId) {
this.assetId = assetId;
}
public Tag getTag() {
return tag;
}
public void setTag(Tag tag) {
this.tag = tag;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/domain/Tag.java | src/main/java/org/ohdsi/webapi/tag/domain/Tag.java | package org.ohdsi.webapi.tag.domain;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.ohdsi.webapi.model.CommonEntity;
import org.ohdsi.webapi.tag.converter.TagTypeConverter;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import java.util.Objects;
import java.util.Set;
@Entity(name = "Tag")
@Table(name = "tag")
public class Tag extends CommonEntity<Integer> {
@Id
@GenericGenerator(
name = "tags_generator",
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
parameters = {
@org.hibernate.annotations.Parameter(name = "sequence_name", value = "tag_seq"),
@Parameter(name = "increment_size", value = "1")
}
)
@GeneratedValue(generator = "tags_generator")
private Integer id;
@ManyToMany(targetEntity = Tag.class, fetch = FetchType.LAZY)
@JoinTable(name = "tag_group",
joinColumns = @JoinColumn(name = "tag_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "group_id", referencedColumnName = "id"))
private Set<Tag> groups;
@Column
private String name;
@Column
@Convert(converter = TagTypeConverter.class)
private TagType type;
@Column(name = "count")
private int count;
@Column(name = "show_group")
private boolean showGroup;
@Column(name = "multi_selection")
private boolean multiSelection;
@Column(name = "permission_protected")
private boolean permissionProtected;
@Column(name = "icon")
private String icon;
@Column(name = "color")
private String color;
@Column(name = "mandatory")
private boolean mandatory;
@Column(name = "allow_custom")
private boolean allowCustom;
@Column(name = "description")
private String description;
@Override
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Set<Tag> getGroups() {
return groups;
}
public void setGroups(Set<Tag> groups) {
this.groups = groups;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public TagType getType() {
return type;
}
public void setType(TagType type) {
this.type = type;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public boolean isShowGroup() {
return showGroup;
}
public void setShowGroup(boolean showGroup) {
this.showGroup = showGroup;
}
public boolean isMultiSelection() {
return multiSelection;
}
public void setMultiSelection(boolean multiSelection) {
this.multiSelection = multiSelection;
}
public boolean isPermissionProtected() {
return permissionProtected;
}
public void setPermissionProtected(boolean permissionProtected) {
this.permissionProtected = permissionProtected;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public boolean isMandatory() {
return mandatory;
}
public void setMandatory(boolean mandatory) {
this.mandatory = mandatory;
}
public boolean isAllowCustom() {
return allowCustom;
}
public void setAllowCustom(boolean allowCustom) {
this.allowCustom = allowCustom;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Tag tag = (Tag) o;
return name.equals(tag.name);
}
@Override
public int hashCode() {
return Objects.hash(name);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/domain/AssetTagPK.java | src/main/java/org/ohdsi/webapi/tag/domain/AssetTagPK.java | package org.ohdsi.webapi.tag.domain;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.io.Serializable;
import java.util.Objects;
@Embeddable
public class AssetTagPK implements Serializable {
@Column(name = "asset_id")
private int assetId;
@Column(name = "tag_id")
private int tagId;
public AssetTagPK() {
}
public AssetTagPK(int assetId, int tagId) {
this.assetId = assetId;
this.tagId = tagId;
}
public int getAssetId() {
return assetId;
}
public void setAssetId(int assetId) {
this.assetId = assetId;
}
public int getTagId() {
return tagId;
}
public void setTagId(int tagId) {
this.tagId = tagId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AssetTagPK that = (AssetTagPK) o;
return assetId == that.assetId && tagId == that.tagId;
}
@Override
public int hashCode() {
return Objects.hash(assetId, tagId);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/repository/TagRepository.java | src/main/java/org/ohdsi/webapi/tag/repository/TagRepository.java | package org.ohdsi.webapi.tag.repository;
import org.ohdsi.webapi.tag.domain.Tag;
import org.ohdsi.webapi.tag.domain.TagInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface TagRepository extends JpaRepository<Tag, Integer> {
@Query("SELECT t FROM Tag t WHERE LOWER(t.name) LIKE LOWER(CONCAT(?1, '%'))")
List<Tag> findAllTags(String namePart);
List<Tag> findByIdIn(List<Integer> ids);
@Query("SELECT ct.assetId.tagId as id, " +
"COUNT(ct.assetId.tagId) AS count " +
"FROM CohortTag ct " +
"GROUP BY ct.assetId.tagId")
List<TagInfo> findCohortTagInfo();
@Query("SELECT cct.assetId.tagId as id, " +
"COUNT(cct.assetId.tagId) AS count " +
"FROM CohortCharacterizationTag cct " +
"GROUP BY cct.assetId.tagId")
List<TagInfo> findCcTagInfo();
@Query("SELECT cst.assetId.tagId as id, " +
"COUNT(cst.assetId.tagId) AS count " +
"FROM ConceptSetTag cst " +
"GROUP BY cst.assetId.tagId")
List<TagInfo> findConceptSetTagInfo();
@Query("SELECT it.assetId.tagId as id, " +
"COUNT(it.assetId.tagId) AS count " +
"FROM IrTag it " +
"GROUP BY it.assetId.tagId")
List<TagInfo> findIrTagInfo();
@Query("SELECT pt.assetId.tagId as id, " +
"COUNT(pt.assetId.tagId) AS count " +
"FROM PathwayTag pt " +
"GROUP BY pt.assetId.tagId")
List<TagInfo> findPathwayTagInfo();
@Query("SELECT rt.assetId.tagId as id, " +
"COUNT(rt.assetId.tagId) AS count " +
"FROM ReusableTag rt " +
"GROUP BY rt.assetId.tagId")
List<TagInfo> findReusableTagInfo();
@Query("SELECT t FROM Tag t WHERE t.mandatory = 'TRUE'")
List<Tag> findMandatoryTags();
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/converter/TagDTOToTagConverter.java | src/main/java/org/ohdsi/webapi/tag/converter/TagDTOToTagConverter.java | package org.ohdsi.webapi.tag.converter;
import org.ohdsi.webapi.service.converters.BaseCommonDTOToEntityConverter;
import org.ohdsi.webapi.tag.domain.Tag;
import org.ohdsi.webapi.tag.dto.TagDTO;
import org.springframework.stereotype.Component;
import java.util.Set;
import java.util.stream.Collectors;
@Component
public class TagDTOToTagConverter extends BaseCommonDTOToEntityConverter<TagDTO, Tag> {
protected Tag createResultObject() {
return new Tag();
}
@Override
protected void doConvert(TagDTO source, Tag target) {
target.setId(source.getId());
Set<Tag> groups = source.getGroups().stream()
.map(t -> conversionService.convert(t, Tag.class))
.collect(Collectors.toSet());
target.setGroups(groups);
target.setName(source.getName());
target.setType(source.getType());
target.setCount(source.getCount());
target.setColor(source.getColor());
target.setIcon(source.getIcon());
target.setShowGroup(source.isShowGroup());
target.setPermissionProtected(source.isPermissionProtected());
target.setMultiSelection(source.isMultiSelection());
target.setMandatory(source.isMandatory());
target.setAllowCustom(source.isAllowCustom());
target.setDescription(source.getDescription());
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/converter/TagTypeConverter.java | src/main/java/org/ohdsi/webapi/tag/converter/TagTypeConverter.java | package org.ohdsi.webapi.tag.converter;
import org.ohdsi.webapi.tag.domain.TagType;
import javax.persistence.AttributeConverter;
public class TagTypeConverter implements AttributeConverter<TagType, Integer> {
@Override
public Integer convertToDatabaseColumn(TagType tagType) {
return tagType.getValue();
}
@Override
public TagType convertToEntityAttribute(Integer tagTypeValue) {
return TagType.fromValue(tagTypeValue);
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/tag/converter/TagToTagDTOConverter.java | src/main/java/org/ohdsi/webapi/tag/converter/TagToTagDTOConverter.java | package org.ohdsi.webapi.tag.converter;
import org.ohdsi.webapi.service.converters.BaseCommonEntityToDTOConverter;
import org.ohdsi.webapi.tag.domain.Tag;
import org.ohdsi.webapi.tag.dto.TagDTO;
import org.springframework.stereotype.Component;
import java.util.Set;
import java.util.stream.Collectors;
@Component
public class TagToTagDTOConverter extends BaseCommonEntityToDTOConverter<Tag, TagDTO> {
@Override
protected void doConvert(Tag source, TagDTO target) {
target.setId(source.getId());
Set<TagDTO> groups = source.getGroups().stream()
.map(t -> conversionService.convert(t, TagDTO.class))
.collect(Collectors.toSet());
target.setGroups(groups);
target.setName(source.getName());
target.setType(source.getType());
target.setCount(source.getCount());
target.setColor(source.getColor());
target.setIcon(source.getIcon());
target.setShowGroup(source.isShowGroup());
target.setPermissionProtected(source.isPermissionProtected());
target.setMultiSelection(source.isMultiSelection());
target.setMandatory(source.isMandatory());
target.setAllowCustom(source.isAllowCustom());
target.setDescription(source.getDescription());
}
protected TagDTO createResultObject() {
return new TagDTO();
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/VocabularySearchProviderType.java | src/main/java/org/ohdsi/webapi/vocabulary/VocabularySearchProviderType.java | package org.ohdsi.webapi.vocabulary;
public enum VocabularySearchProviderType {
DATABASE,
SOLR
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/RelatedConceptSearch.java | src/main/java/org/ohdsi/webapi/vocabulary/RelatedConceptSearch.java | /*
* 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.vocabulary;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
* @author asena5
*/
public class RelatedConceptSearch {
public RelatedConceptSearch() {
}
@JsonProperty("VOCABULARY_ID")
public String[] vocabularyId;
@JsonProperty("CONCEPT_CLASS_ID")
public String[] conceptClassId;
@JsonProperty("CONCEPT_ID")
public long[] conceptId;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/DatabaseSearchProvider.java | src/main/java/org/ohdsi/webapi/vocabulary/DatabaseSearchProvider.java | package org.ohdsi.webapi.vocabulary;
import java.util.Collection;
import org.ohdsi.vocabulary.Concept;
import org.ohdsi.vocabulary.SearchProvider;
import org.ohdsi.vocabulary.SearchProviderConfig;
import org.ohdsi.webapi.service.VocabularyService;
import org.ohdsi.webapi.source.Source;
import org.ohdsi.webapi.source.SourceRepository;
import org.ohdsi.webapi.util.PreparedStatementRenderer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class DatabaseSearchProvider implements SearchProvider {
@Autowired
private SourceRepository sourceRepository;
private final static int VOCABULARY_PRIORITY = Integer.MAX_VALUE;
@Autowired
VocabularyService vocabService;
@Override
public boolean supports(String vocabularyVersionKey) {
return true;
}
@Override
public int getPriority() {
return VOCABULARY_PRIORITY;
}
@Override
public Collection<Concept> executeSearch(SearchProviderConfig config, String query, String rows) throws Exception {
Source source = sourceRepository.findBySourceKey(config.getSourceKey());
PreparedStatementRenderer psr = vocabService.prepareExecuteSearchWithQuery(query, source);
return vocabService.getSourceJdbcTemplate(source).query(psr.getSql(), psr.getSetter(), vocabService.getRowMapper());
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/Domain.java | src/main/java/org/ohdsi/webapi/vocabulary/Domain.java | package org.ohdsi.webapi.vocabulary;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
* @author fdefalco
*/
public class Domain {
@JsonProperty("DOMAIN_NAME")
public String domainName;
@JsonProperty("DOMAIN_ID")
public String domainId;
@JsonProperty("DOMAIN_CONCEPT_ID")
public long domainConceptId;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/ConceptSearch.java | src/main/java/org/ohdsi/webapi/vocabulary/ConceptSearch.java | package org.ohdsi.webapi.vocabulary;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
* @author fdefalco
*/
public class ConceptSearch {
public ConceptSearch() {
}
@JsonProperty("QUERY")
public String query;
@JsonProperty("DOMAIN_ID")
public String[] domainId;
@JsonProperty("VOCABULARY_ID")
public String[] vocabularyId;
@JsonProperty("STANDARD_CONCEPT")
public String standardConcept;
@JsonProperty("INVALID_REASON")
public String invalidReason;
@JsonProperty("CONCEPT_CLASS_ID")
public String[] conceptClassId;
@JsonProperty("IS_LEXICAL")
public boolean isLexical;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/DescendentOfAncestorSearch.java | src/main/java/org/ohdsi/webapi/vocabulary/DescendentOfAncestorSearch.java | /*
* 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.vocabulary;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
* @author anthonygsena
*/
public class DescendentOfAncestorSearch {
public DescendentOfAncestorSearch() {
}
@JsonProperty("CONCEPT_ID")
public String conceptId;
@JsonProperty("ANCESTOR_VOCABULARY_ID")
public String ancestorVocabularyId;
@JsonProperty("ANCESTOR_CLASS_ID")
public String ancestorClassId;
@JsonProperty("SIBLING_VOCABULARY_ID")
public String siblingVocabularyId;
@JsonProperty("SIBLING_CLASS_ID")
public String siblingClassId;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/VocabularySearchServiceImpl.java | src/main/java/org/ohdsi/webapi/vocabulary/VocabularySearchServiceImpl.java | package org.ohdsi.webapi.vocabulary;
import java.util.Arrays;
import java.util.Comparator;
import org.ohdsi.vocabulary.SearchProvider;
import org.ohdsi.vocabulary.SearchProviderConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@Service
public class VocabularySearchServiceImpl implements VocabularySearchService {
protected final Logger log = LoggerFactory.getLogger(getClass());
private static final String NO_PROVIDER_ERROR = "There is no vocabulary search provider which for sourceKey: %s";
private final SearchProvider[] searchProviders;
public VocabularySearchServiceImpl(SearchProvider[] searchProviders) {
this.searchProviders = searchProviders;
}
@Override
public SearchProvider getSearchProvider(SearchProviderConfig config) {
return Arrays.stream(searchProviders)
.sorted(Comparator.comparingInt(SearchProvider::getPriority))
.filter(p -> p.supports(config.getVersionKey()))
.findFirst()
.orElseThrow(() -> new RuntimeException(String.format(NO_PROVIDER_ERROR, config.getSourceKey())));
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/ConceptRecommendedNotInstalledException.java | src/main/java/org/ohdsi/webapi/vocabulary/ConceptRecommendedNotInstalledException.java | /*
* Copyright 2022 cknoll1.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.vocabulary;
/**
*
* @author cknoll1
*/
public class ConceptRecommendedNotInstalledException extends RuntimeException{
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/RelatedConcept.java | src/main/java/org/ohdsi/webapi/vocabulary/RelatedConcept.java | package org.ohdsi.webapi.vocabulary;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import org.ohdsi.vocabulary.Concept;
/**
*
* @author fdefalco
*/
@JsonInclude(Include.NON_NULL)
public class RelatedConcept extends Concept {
@JsonProperty("RELATIONSHIPS")
public ArrayList<ConceptRelationship> relationships;
public RelatedConcept() {
relationships = new ArrayList<>();
}
@JsonProperty("RELATIONSHIP_CAPTION")
public String GetRelationshipCaption() {
String result = "";
for (int i = 0; i < relationships.size(); i++) {
if (i > 0)
result += ", ";
result += relationships.get(i).relationshipName;
}
return result;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/VocabularySearchService.java | src/main/java/org/ohdsi/webapi/vocabulary/VocabularySearchService.java | package org.ohdsi.webapi.vocabulary;
import org.ohdsi.vocabulary.SearchProvider;
import org.ohdsi.vocabulary.SearchProviderConfig;
public interface VocabularySearchService {
SearchProvider getSearchProvider(SearchProviderConfig config);
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/ConceptSetCondenser.java | src/main/java/org/ohdsi/webapi/vocabulary/ConceptSetCondenser.java | /** *****************************************************************************
* Copyright 2025 Observational Health Data Sciences and Informatics
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************** */
package org.ohdsi.webapi.vocabulary;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class ConceptSetCondenser {
private Set<Long> includedConcepts;
private List<CandidateConcept> candidateConcepts;
private CandidateConcept.Options[] currentSolution;
private CandidateConcept.Options[] optimalSolution;
private int optimalLength;
private int firstExclusionIndex;
private List<Set<Long>> remainingConceptsAtLevel;
private long stepCount;
private static long MAX_STEP_COUNT = 10000000;
/**
* Constructor
*
* @param includedConcepts The set of concept IDs included in the concept set.
* @param candidateConcepts An array of candidate concepts. A candidate
* concept is either in the concept set, or is a descendant of a concept in
* the concept set.
*/
public ConceptSetCondenser(long[] includedConcepts, CandidateConcept[] candidateConcepts) {
this.includedConcepts = new HashSet<>(includedConcepts.length);
for (long concept : includedConcepts) {
this.includedConcepts.add(concept);
}
this.candidateConcepts = new ArrayList<>(candidateConcepts.length);
Set<Long> candidateConceptIds = new HashSet<>(candidateConcepts.length);
for (CandidateConcept candidateConcept : candidateConcepts) {
this.candidateConcepts.add(candidateConcept);
candidateConceptIds.add(candidateConcept.conceptId);
}
if (!candidateConceptIds.containsAll(this.includedConcepts)) {
throw new IllegalArgumentException("Not all included concepts are in the set of candidate concepts");
}
}
/**
* Encapsulates a concept ID and the exclude/descendant flags.
*/
public class ConceptExpression {
public long conceptId;
public boolean exclude;
public boolean descendants;
public ConceptExpression(long conceptId, boolean exclude, boolean descendants) {
this.conceptId = conceptId;
this.exclude = exclude;
this.descendants = descendants;
}
public void print() {
System.out.println("Concept ID: " + conceptId + ", exclude: " + exclude + ", descendants: " + descendants);
}
}
/**
* Encapsulates the conceptId and concept's descendants and is used to capture
* the options required for the final solution.
*/
public static class CandidateConcept {
public enum Options {
INCLUDE, INCLUDE_WITH_DESCENDANTS, EXCLUDE, EXCLUDE_WITH_DESCENDANTS, IGNORE
}
public long conceptId;
public Set<Long> descendants;
public Options[] validOptions;
public boolean inConceptSet;
public int relevantDescendantCount;
/**
* @param conceptId The concept ID
* @param descendants All descendant concept IDs. This follows OHDSI
* convention that the descendants include the concept set itself, so the
* minimum size is 1.
*/
public CandidateConcept(long conceptId, long[] descendants) {
this.conceptId = conceptId;
this.descendants = new HashSet<>(descendants.length);
for (long descendant : descendants) {
this.descendants.add(descendant);
}
if (!this.descendants.contains(conceptId)) {
throw new IllegalArgumentException("Descendants do not include concept itself for concept " + conceptId);
}
}
public boolean hasValidOption(Options option) {
for (Options validOption : validOptions) {
if (validOption == option) {
return true;
}
}
return false;
}
}
/**
* Condense the concept set to the optimal (shortest) expression.
*/
public void condense() {
determineValidStatesAndRemoveRedundant();
bruteForceSearch();
}
/**
* Get the optimal concept set expression. Will throw an exception if
* condense() hasn't been called first.
*
* @return An array of ConceptExpression
*/
public ConceptExpression[] getConceptSetExpression() {
if (optimalLength == -1) {
throw new RuntimeException("Must run condense() first");
}
ConceptExpression[] expression = new ConceptExpression[optimalLength];
int cursor = 0;
for (int i = 0; i < optimalSolution.length; i++) {
long conceptId = candidateConcepts.get(i).conceptId;
switch (optimalSolution[i]) {
case INCLUDE:
expression[cursor++] = new ConceptExpression(conceptId, false, false);
break;
case INCLUDE_WITH_DESCENDANTS:
expression[cursor++] = new ConceptExpression(conceptId, false, true);
break;
case EXCLUDE:
expression[cursor++] = new ConceptExpression(conceptId, true, false);
break;
case EXCLUDE_WITH_DESCENDANTS:
expression[cursor++] = new ConceptExpression(conceptId, true, true);
break;
case IGNORE:
break;
}
}
return expression;
}
private void bruteForceSearch() {
// Sort candidate concepts to determine order in which tree is traversed.
// First sorting so inclusions are executed first. This allows us to build the concept set
// on the fly (exclusions must always be done last).
// Then sorting so inclusions that are not optional are done first. This just means they are
// not re-evaluated all the time
// Finally sorting by the size of descendants. Since IGNORE is the first option
// that is evaluated, this means in the first part of the tree search we will evaluate
// options where these lower-level concepts are ignored.
Comparator<CandidateConcept> comparator = (CandidateConcept obj1, CandidateConcept obj2) -> {
int result = Boolean.compare(obj2.inConceptSet, obj1.inConceptSet);
if (result != 0) {
return result;
}
result = Boolean.compare(obj2.validOptions.length == 1, obj1.validOptions.length == 1);
if (result != 0) {
return result;
}
return Integer.compare(obj2.relevantDescendantCount, obj1.relevantDescendantCount);
};
candidateConcepts.sort(comparator);
// At each level in the tree, determine what concepts could still be included or excluded from
// that point forward. This will help terminate a branch when it cannot achieve a valid solution:
firstExclusionIndex = candidateConcepts.size();
remainingConceptsAtLevel = new ArrayList<>(candidateConcepts.size());
Set<Long> remainingConcepts = new HashSet<>();
for (int i = candidateConcepts.size() - 1; i >= 0; i--) {
CandidateConcept candidateConcept = candidateConcepts.get(i);
if (candidateConcept.inConceptSet) {
if (i == firstExclusionIndex - 1) {
remainingConcepts.clear();
}
if (candidateConcept.hasValidOption(CandidateConcept.Options.INCLUDE_WITH_DESCENDANTS)) {
remainingConcepts.addAll(candidateConcept.descendants);
} else {
remainingConcepts.add(candidateConcept.conceptId);
}
} else {
firstExclusionIndex = i;
if (candidateConcept.hasValidOption(CandidateConcept.Options.EXCLUDE_WITH_DESCENDANTS)) {
remainingConcepts.addAll(candidateConcept.descendants);
} else {
remainingConcepts.add(candidateConcept.conceptId);
}
}
remainingConceptsAtLevel.add(new HashSet<>(remainingConcepts));
}
Collections.reverse(remainingConceptsAtLevel);
optimalLength = candidateConcepts.size() + 1;
optimalSolution = new CandidateConcept.Options[candidateConcepts.size()];
currentSolution = new CandidateConcept.Options[candidateConcepts.size()];
stepCount = 0;
recurseOverOptions(0, 0, new HashSet<>());
if (stepCount >= MAX_STEP_COUNT) {
System.out.println("Reached max step count. Solution may not be optimal");
}
}
private void recurseOverOptions(int index, int currentLength, Set<Long> currentConceptSet) {
stepCount++;
if (stepCount > MAX_STEP_COUNT) {
return;
} else if (currentLength >= optimalLength) {
// Already cannot improve on current best solution
return;
} else if (index == candidateConcepts.size()) {
evaluateCurrentSolution(currentLength, currentConceptSet);
} else if (index == firstExclusionIndex && !currentConceptSet.containsAll(includedConcepts)) {
// Only exclusion options from here on, so if not all required concepts are in current
// set there is no way to add them
return;
} else {
if (index < firstExclusionIndex) {
Set<Long> missingConcepts = new HashSet<>(includedConcepts);
missingConcepts.removeAll(currentConceptSet);
if (!remainingConceptsAtLevel.get(index).containsAll(missingConcepts)) {
return;
}
} else {
Set<Long> surplusConcepts = new HashSet<>(currentConceptSet);
surplusConcepts.removeAll(includedConcepts);
if (!remainingConceptsAtLevel.get(index).containsAll(surplusConcepts)) {
return;
}
}
CandidateConcept candidateConcept = candidateConcepts.get(index);
for (CandidateConcept.Options option : candidateConcept.validOptions) {
currentSolution[index] = option;
Set<Long> newConceptSet;
int newLength = currentLength;
switch (option) {
case INCLUDE:
if (currentConceptSet.contains(candidateConcept.conceptId)) {
continue;
}
newConceptSet = new HashSet<>(currentConceptSet);
newConceptSet.add(candidateConcept.conceptId);
newLength++;
break;
case INCLUDE_WITH_DESCENDANTS:
if (currentConceptSet.containsAll(candidateConcept.descendants)) {
continue;
}
Set<Long> surplusConcepts = new HashSet<>(candidateConcept.descendants);
surplusConcepts.removeAll(currentConceptSet);
if (Collections.disjoint(includedConcepts, surplusConcepts)) {
continue;
}
newConceptSet = new HashSet<>(currentConceptSet);
newConceptSet.addAll(candidateConcept.descendants);
newLength++;
break;
case EXCLUDE:
if (!currentConceptSet.contains(candidateConcept.conceptId)
|| includedConcepts.contains(candidateConcept.conceptId)) {
continue;
}
newConceptSet = new HashSet<>(currentConceptSet);
newConceptSet.remove(candidateConcept.conceptId);
newLength++;
break;
case EXCLUDE_WITH_DESCENDANTS:
if (Collections.disjoint(currentConceptSet, candidateConcept.descendants)) {
continue;
}
newConceptSet = new HashSet<>(currentConceptSet);
newConceptSet.removeAll(candidateConcept.descendants);
newLength++;
break;
default:
// IGNORE
newConceptSet = currentConceptSet;
break;
}
recurseOverOptions(index + 1, newLength, newConceptSet);
}
}
}
private void evaluateCurrentSolution(int currentLength, Set<Long> currentConceptSet) {
if (currentConceptSet.equals(includedConcepts)) {
if (currentLength < optimalLength) {
optimalSolution = Arrays.copyOf(currentSolution, currentSolution.length);
optimalLength = currentLength;
}
}
}
private void determineValidStatesAndRemoveRedundant() {
Set<Long> candidatesToRemove = new HashSet<>();
List<CandidateConcept.Options> validOptions = new ArrayList<>(5);
for (CandidateConcept candidateConcept : candidateConcepts) {
if (candidatesToRemove.contains(candidateConcept.conceptId)) {
continue;
}
validOptions.clear();
if (includedConcepts.contains(candidateConcept.conceptId)) {
// Concept is in the concept set
candidateConcept.inConceptSet = true;
// If concept is not a descendant of any other concept, it is not an option to
// ignore it
if (!cantIgnore(candidateConcept)) {
validOptions.add(CandidateConcept.Options.IGNORE);
}
if (candidateConcept.descendants.size() == 1) {
// Has no descendants, so no difference between INCLUDE and
// INCLUDE_WITH_DESCENDANTS
validOptions.add(CandidateConcept.Options.INCLUDE_WITH_DESCENDANTS);
candidateConcept.relevantDescendantCount = 1;
} else {
if (includedConcepts.containsAll(candidateConcept.descendants)) {
// All descendants are in concept set, so no reason to evaluate
// INCLUDE
validOptions.add(CandidateConcept.Options.INCLUDE_WITH_DESCENDANTS);
candidateConcept.relevantDescendantCount = candidateConcept.descendants.size();
// Also, descendants are redundant, so can be removed from candidate list:
Set<Long> toRemove = new HashSet<>(candidateConcept.descendants);
toRemove.remove(candidateConcept.conceptId);
candidatesToRemove.addAll(toRemove);
} else {
validOptions.add(CandidateConcept.Options.INCLUDE);
validOptions.add(CandidateConcept.Options.INCLUDE_WITH_DESCENDANTS);
Set<Long> intersection = new HashSet<>(candidateConcept.descendants);
intersection.retainAll(includedConcepts);
candidateConcept.relevantDescendantCount = intersection.size();
}
}
} else {
// Concept is *not* in the concept set
candidateConcept.inConceptSet = false;
candidateConcept.relevantDescendantCount = candidateConcept.descendants.size();
validOptions.add(CandidateConcept.Options.IGNORE);
if (candidateConcept.descendants.size() == 1) {
// Has no descendants, so no difference between EXCLUDE and
// EXCLUDE_WITH_DESCENDANTS
validOptions.add(CandidateConcept.Options.EXCLUDE_WITH_DESCENDANTS);
} else {
validOptions.add(CandidateConcept.Options.EXCLUDE);
if (Collections.disjoint(includedConcepts, candidateConcept.descendants)) {
// None of the descendants are in concept set, so can EXCLUDE_WITH_DESCENDANTS
validOptions.add(CandidateConcept.Options.EXCLUDE_WITH_DESCENDANTS);
// Also, descendants are redundant, so can be removed from candidate list:
Set<Long> toRemove = new HashSet<>(candidateConcept.descendants);
toRemove.remove(candidateConcept.conceptId);
candidatesToRemove.addAll(toRemove);
}
}
}
candidateConcept.validOptions = validOptions.toArray(new CandidateConcept.Options[validOptions.size()]);
}
candidateConcepts.removeIf(candidateConcept -> candidatesToRemove.contains(candidateConcept.conceptId));
}
private boolean cantIgnore(CandidateConcept candidateConcept) {
for (CandidateConcept otherCandidateConcept : candidateConcepts) {
if (otherCandidateConcept != candidateConcept) {
if (otherCandidateConcept.descendants.contains(candidateConcept.conceptId)) {
return false;
}
}
}
return true;
}
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/RecommendedConcept.java | src/main/java/org/ohdsi/webapi/vocabulary/RecommendedConcept.java | /*
* Copyright 2022 cknoll1.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.vocabulary;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import org.ohdsi.circe.vocabulary.Concept;
/**
*
* @author cknoll1
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RecommendedConcept extends Concept {
@JsonProperty("RELATIONSHIPS")
public ArrayList<String> relationships = new ArrayList<>();
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/MappedRelatedConcept.java | src/main/java/org/ohdsi/webapi/vocabulary/MappedRelatedConcept.java | package org.ohdsi.webapi.vocabulary;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Set;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MappedRelatedConcept extends RelatedConcept {
@JsonProperty("mapped_from")
public Set<Long> mappedFromIds;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/ConceptRelationship.java | src/main/java/org/ohdsi/webapi/vocabulary/ConceptRelationship.java | package org.ohdsi.webapi.vocabulary;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
* @author fdefalco
*/
@JsonInclude(Include.NON_NULL)
public class ConceptRelationship {
@JsonProperty("RELATIONSHIP_NAME")
public String relationshipName;
@JsonProperty("RELATIONSHIP_DISTANCE")
public int relationshipDistance;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/Vocabulary.java | src/main/java/org/ohdsi/webapi/vocabulary/Vocabulary.java | package org.ohdsi.webapi.vocabulary;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
* @author fdefalco
*/
public class Vocabulary {
@JsonProperty("VOCABULARY_ID")
public String vocabularyId;
@JsonProperty("VOCABULARY_NAME")
public String vocabularyName;
@JsonProperty("VOCABULARY_REFERENCE")
public String vocabularyReference;
@JsonProperty("VOCABULARY_VERSION")
public String vocabularyVersion;
@JsonProperty("VOCABULARY_CONCEPT_ID")
public long vocabularyConceptId;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/vocabulary/VocabularyInfo.java | src/main/java/org/ohdsi/webapi/vocabulary/VocabularyInfo.java | /*
* 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.vocabulary;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
*
* @author fdefalco
*/
public class VocabularyInfo {
@JsonProperty("version")
public String version;
@JsonProperty("dialect")
public String dialect;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/evidence/EvidenceSummary.java | src/main/java/org/ohdsi/webapi/evidence/EvidenceSummary.java | /*
* Copyright 2015 fdefalco.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.evidence;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;
import java.math.BigInteger;
/**
*
* @author fdefalco
*/
public class EvidenceSummary {
@JsonProperty("evidence_group_name")
public String evidence_group_name;
@JsonProperty("evidence_id")
public BigInteger evidence_id;
@JsonProperty("evidence_type")
public String evidence_type;
@JsonProperty("supports")
public boolean supports;
@JsonProperty("evidence_count")
public double evidence_count;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/evidence/Evidence.java | src/main/java/org/ohdsi/webapi/evidence/Evidence.java | /*
* Copyright 2015 fdefalco.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ohdsi.webapi.evidence;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.math.BigDecimal;
/**
*
* @author fdefalco
*/
public class Evidence {
@JsonProperty("evidenceSource")
public String evidenceSource;
@JsonProperty("relationshipType")
public String relationshipType;
@JsonProperty("statisticType")
public String statisticType;
@JsonProperty("statisticValue")
public BigDecimal statisticValue;
@JsonProperty("drugConceptId")
public String drugConceptId;
@JsonProperty("drugConceptName")
public String drugConceptName;
@JsonProperty("hoiConceptId")
public String hoiConceptId;
@JsonProperty("hoiConceptName")
public String hoiConceptName;
@JsonProperty("uniqueIdentifier")
public String uniqueIdentifier;
@JsonProperty("uniqueIdentifierType")
public String uniqueIdentifierType;
@JsonProperty("count")
public Integer count;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
OHDSI/WebAPI | https://github.com/OHDSI/WebAPI/blob/b22d7bf02d98c0cf78c46801877368d6ecad2245/src/main/java/org/ohdsi/webapi/evidence/DrugLabelInfo.java | src/main/java/org/ohdsi/webapi/evidence/DrugLabelInfo.java | package org.ohdsi.webapi.evidence;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DrugLabelInfo {
@JsonProperty("conceptId")
public String conceptId;
@JsonProperty("conceptName")
public String conceptName;
@JsonProperty("usaProductLabelExists")
public Integer usaProductLabelExists;
}
| java | Apache-2.0 | b22d7bf02d98c0cf78c46801877368d6ecad2245 | 2026-01-05T02:37:20.475642Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.