Skip to content

Commit e7413ab

Browse files
committed
feat: remove deprecated breakdown stats method
1 parent 1665ded commit e7413ab

File tree

2 files changed

+4
-49
lines changed

2 files changed

+4
-49
lines changed

models/concept.go

+4-39
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ type ConceptI interface {
1313
RetrieveInfoBySourceIdAndConceptIds(sourceId int, conceptIds []int64) ([]*ConceptSimple, error)
1414
RetrieveInfoBySourceIdAndConceptTypes(sourceId int, conceptTypes []string) ([]*ConceptSimple, error)
1515
RetrieveBreakdownStatsBySourceIdAndCohortId(sourceId int, cohortDefinitionId int, breakdownConceptId int64) ([]*ConceptBreakdown, error)
16-
RetrieveBreakdownStatsBySourceIdAndCohortIdAndConceptIdsAndCohortPairs(sourceId int, cohortDefinitionId int, filterConceptIds []int64, filterCohortPairs []utils.CustomDichotomousVariableDef, breakdownConceptId int64) ([]*ConceptBreakdown, error)
1716
RetrieveBreakdownStatsBySourceIdAndCohortIdAndConceptDefsPlusCohortPairs(sourceId int, cohortDefinitionId int, filterConceptDefsAndCohortPairs []interface{}, breakdownConceptId int64) ([]*ConceptBreakdown, error)
1817
}
1918
type Concept struct {
@@ -133,50 +132,16 @@ func (h Concept) RetrieveBreakdownStatsBySourceIdAndCohortId(sourceId int, cohor
133132
return h.RetrieveBreakdownStatsBySourceIdAndCohortIdAndConceptDefsPlusCohortPairs(sourceId, cohortDefinitionId, filterConceptDefsAndCohortPairs, breakdownConceptId)
134133
}
135134

136-
// DEPRECATED - use RetrieveBreakdownStatsBySourceIdAndCohortIdAndConceptDefsPlusCohortPairs instead.
137135
// Basically same goal as described in function above, but only count persons that have a non-null value for each
138-
// of the ids in the given filterConceptIds. So, using the example documented in the function above, it will
136+
// of the given filters. So, using the example documented in the function above, it will
139137
// return something like:
140138
//
141139
// {ConceptValue: "A", NPersonsInCohortWithValue: M-X},
142140
// {ConceptValue: "B", NPersonsInCohortWithValue: N-M-X},
143141
//
144-
// where X is the number of persons that have NO value or just a "null" value for one or more of the ids in the given filterConceptIds.
145-
func (h Concept) RetrieveBreakdownStatsBySourceIdAndCohortIdAndConceptIdsAndCohortPairs(sourceId int, cohortDefinitionId int, filterConceptIds []int64, filterCohortPairs []utils.CustomDichotomousVariableDef, breakdownConceptId int64) ([]*ConceptBreakdown, error) {
146-
147-
var dataSourceModel = new(Source)
148-
omopDataSource := dataSourceModel.GetDataSource(sourceId, Omop)
149-
resultsDataSource := dataSourceModel.GetDataSource(sourceId, Results)
150-
151-
// count persons, grouping by concept value:
152-
var conceptBreakdownList []*ConceptBreakdown
153-
query := QueryFilterByCohortPairsHelper(filterCohortPairs, resultsDataSource, cohortDefinitionId, "unionAndIntersect").
154-
Select("observation.value_as_concept_id, count(distinct(observation.person_id)) as npersons_in_cohort_with_value").
155-
Joins("INNER JOIN "+omopDataSource.Schema+".observation_continuous as observation"+omopDataSource.GetViewDirective()+" ON unionAndIntersect.subject_id = observation.person_id").
156-
Where("observation.observation_concept_id = ?", breakdownConceptId).
157-
Where(GetConceptValueNotNullCheckBasedOnConceptType("observation", sourceId, breakdownConceptId))
158-
159-
query = QueryFilterByConceptIdsHelper(query, sourceId, filterConceptIds, omopDataSource, resultsDataSource.Schema, "unionAndIntersect.subject_id")
160-
161-
query, cancel := utils.AddTimeoutToQuery(query)
162-
defer cancel()
163-
meta_result := query.Group("observation.value_as_concept_id").
164-
Scan(&conceptBreakdownList)
165-
166-
// Add concept value (coded value) and concept name for each of the value_as_concept_id values:
167-
for _, conceptBreakdownItem := range conceptBreakdownList {
168-
conceptInfo, error := h.RetrieveInfoBySourceIdAndConceptId(sourceId, conceptBreakdownItem.ValueAsConceptId)
169-
if error != nil {
170-
return nil, error
171-
}
172-
conceptBreakdownItem.ConceptValue = conceptInfo.ConceptCode
173-
conceptBreakdownItem.ValueName = conceptInfo.ConceptName
174-
}
175-
return conceptBreakdownList, meta_result.Error
176-
}
177-
178-
// Same as RetrieveBreakdownStatsBySourceIdAndCohortIdAndConceptIdsAndCohortPairs above, but
179-
// applies transformations and filtering, if these items are specified for the given concept definitions.
142+
// where X is the number of persons that have NO value or just a "null" value for one or more of the concepts in the given filters.
143+
// Also supports cohort pairs in filters, filtering out persons that don't pass the cohort pair filter (drill down to that method for detais).
144+
// Furthermore, this method also applies transformations and filtering, if these items are specified for the given concept definitions.
180145
func (h Concept) RetrieveBreakdownStatsBySourceIdAndCohortIdAndConceptDefsPlusCohortPairs(sourceId int, cohortDefinitionId int, filterConceptDefsAndCohortPairs []interface{}, breakdownConceptId int64) ([]*ConceptBreakdown, error) {
181146
var dataSourceModel = new(Source)
182147
omopDataSource := dataSourceModel.GetDataSource(sourceId, Omop)

tests/controllers_tests/controllers_test.go

-10
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,6 @@ func (h dummyConceptDataModel) RetrieveBreakdownStatsBySourceIdAndCohortId(sourc
263263
}
264264
return conceptBreakdown, nil
265265
}
266-
func (h dummyConceptDataModel) RetrieveBreakdownStatsBySourceIdAndCohortIdAndConceptIdsAndCohortPairs(sourceId int, cohortDefinitionId int, filterConceptIds []int64, filterCohortPairs []utils.CustomDichotomousVariableDef, breakdownConceptId int64) ([]*models.ConceptBreakdown, error) {
267-
conceptBreakdown := []*models.ConceptBreakdown{
268-
{ConceptValue: "value1", NpersonsInCohortWithValue: 4 - len(filterCohortPairs)}, // simulate decreasing numbers as filter increases - the use of filterCohortPairs instead of filterConceptIds is otherwise meaningless here...
269-
{ConceptValue: "value2", NpersonsInCohortWithValue: 7 - len(filterConceptIds)}, // simulate decreasing numbers as filter increases- the use of filterConceptIds instead of filterCohortPairs is otherwise meaningless here...
270-
}
271-
if dummyModelReturnError {
272-
return nil, fmt.Errorf("error!")
273-
}
274-
return conceptBreakdown, nil
275-
}
276266
func (h dummyConceptDataModel) RetrieveBreakdownStatsBySourceIdAndCohortIdAndConceptDefsPlusCohortPairs(sourceId int, cohortDefinitionId int, filterConceptDefsAndCohortPairs []interface{}, breakdownConceptId int64) ([]*models.ConceptBreakdown, error) {
277267
filterConceptDefs, filterCohortPairs := utils.GetConceptDefsAndValuesAndCohortPairsAsSeparateLists(filterConceptDefsAndCohortPairs)
278268

0 commit comments

Comments
 (0)