Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] AssertionError: c.occurrence !== nothing -- What Does This Mean? #8

Closed
TheCedarPrince opened this issue Feb 24, 2024 · 2 comments

Comments

@TheCedarPrince
Copy link

I am seeing this error:

ERROR: AssertionError: c.occurrence !== nothing && c.occurr
ence.count_column === nothing
Stacktrace:
  [1] predicate(c::OHDSICohortExpressions.CorrelatedCriteri
a, ctx::OHDSICohortExpressions.TranslateContext)
    @ OHDSICohortExpressions ~/.julia/packages/OHDSICohortE
xpressions/UuDrd/src/translate.jl:725
  [2] predicate(c::OHDSICohortExpressions.CriteriaGroup, ct
x::OHDSICohortExpressions.TranslateContext)
    @ OHDSICohortExpressions ~/.julia/packages/OHDSICohortE
xpressions/UuDrd/src/translate.jl:627
  [3] 
    @ OHDSICohortExpressions ~/.julia/packages/OHDSICohortE
xpressions/UuDrd/src/translate.jl:568
  [4] translate
    @ ~/.julia/packages/OHDSICohortExpressions/UuDrd/src/tr
anslate.jl:554 [inlined]
  [5] translate(c::OHDSICohortExpressions.CohortExpression,
 ctx::OHDSICohortExpressions.TranslateContext)
    @ OHDSICohortExpressions ~/.julia/packages/OHDSICohortE
xpressions/UuDrd/src/translate.jl:141
  [6] translate
    @ ~/.julia/packages/OHDSICohortExpressions/UuDrd/src/tr
anslate.jl:103 [inlined]
  [7] translate(cohort::Dict{String, Any}, dialect::Symbol,
 model::Model, cohort_definition_id::Int64)
    @ OHDSICohortExpressions ~/.julia/packages/OHDSICohortE
xpressions/UuDrd/src/translate.jl:46
  [8] translate(cohort::String, dialect::Symbol, model::Mod
el, cohort_definition_id::Int64)
    @ OHDSICohortExpressions ~/.julia/packages/OHDSICohortE
xpressions/UuDrd/src/translate.jl:41
  [9] #translate#79
    @ ~/.julia/packages/OHDSICohortExpressions/UuDrd/src/tr
anslate.jl:38 [inlined]
 [10] (::var"#32#33")(f::IOStream)
    @ Main ./REPL[99]:23
 [11] open(::var"#32#33", ::String, ::Vararg{String}; kwarg
s::@Kwargs{})
    @ Base ./io.jl:396
 [12] open(::Function, ::String, ::String)
    @ Base ./io.jl:393
 [13] top-level scope
    @ REPL[99]:1
Some type information was truncated. Use `show(err)` to see
 complete types.

When I run this code:

cohort_expression = 
"""
{
     "cdmVersionRange": ">=5.0.0",
     "PrimaryCriteria": {
                                   "CriteriaList": [
                                                     {
                                                        "VisitOccurrence": {
                                                                              "VisitTypeExclude": false
                                                                           }
                                                     }
                                                   ],
                              "ObservationWindow": {
                                                      "PriorDays": 0,
                                                       "PostDays": 0
                                                   },
                           "PrimaryCriteriaLimit": {
                                                      "Type": "First"
                                                   }
                        },
         "ConceptSets": [
                          {
                                     "id": 0,
                                   "name": "Amitriptyline",
                             "expression": {
                                              "items": [
                                                         {
                                                                       "concept": {
                                                                                                   "CONCEPT_ID": 710062,
                                                                                                 "CONCEPT_NAME": "amitriptyline",
                                                                                             "STANDARD_CONCEPT": "S",
                                                                                     "STANDARD_CONCEPT_CAPTION": "Standard",
                                                                                               "INVALID_REASON": "V",
                                                                                       "INVALID_REASON_CAPTION": "Valid",
                                                                                                 "CONCEPT_CODE": "704",
                                                                                                    "DOMAIN_ID": "Drug",
                                                                                                "VOCABULARY_ID": "RxNorm",
                                                                                             "CONCEPT_CLASS_ID": "Ingredient"
                                                                                  },
                                                                    "isExcluded": false,
                                                            "includeDescendants": true,
                                                                 "includeMapped": false
                                                         }
                                                       ]
                                           }
                          }
                        ],
      "QualifiedLimit": {
                           "Type": "First"
                        },
     "ExpressionLimit": {
                           "Type": "First"
                        },
      "InclusionRules": [
                          {
                                   "name": "has Amitriptyline exposure",
                             "expression": {
                                                                 "Type": "ALL",
                                                         "CriteriaList": [
                                                                           {
                                                                                             "Criteria": {
                                                                                                            "DrugExposure": {
                                                                                                                                     "CodesetId": 0,
                                                                                                                               "DrugTypeExclude": false
                                                                                                                            }
                                                                                                         },
                                                                                          "StartWindow": {
                                                                                                                  "Start": {
                                                                                                                              "Coeff": -1
                                                                                                                           },
                                                                                                                    "End": {
                                                                                                                              "Coeff": 1
                                                                                                                           },
                                                                                                            "UseIndexEnd": false,
                                                                                                            "UseEventEnd": false
                                                                                                         },
                                                                                        "RestrictVisit": false,
                                                                              "IgnoreObservationPeriod": false,
                                                                                           "Occurrence": {
                                                                                                                   "Type": 2,
                                                                                                                  "Count": 1,
                                                                                                             "IsDistinct": false,
                                                                                                            "CountColumn": "DOMAIN_CONCEPT"
                                                                                                         }
                                                                           }
                                                                         ],
                                              "DemographicCriteriaList": [],
                                                               "Groups": []
                                           }
                          }
                        ],
   "CensoringCriteria": [],
    "CollapseSettings": {
                           "CollapseType": "ERA",
                                 "EraPad": 0
                        },
        "CensorWindow": {}
}
"""
            model = Model(cdm_version = v"5.3.1", 
                          cdm_schema = "omop",
                          vocabulary_schema = "omop", 
                          results_schema = "omop",
                          target_schema = "omop",
                          target_table = "cohort");

            sql = translate(cohort_expression, 
                            dialect = :postgresql, 
                            model = model,
                            cohort_definition_id = id);

Do you know what is going on here and how I could fix it? Thanks!

@clarkevans
Copy link
Contributor

[BUG] AssertionError: c.occurrence !== nothing -- What Does This Mean?

We did not implement every aspect of the OHDSI cohort expression object, only those that were used in the phenotype library. Why? We would like to ensure that things implemented are actually tested. I think for each case like this, what we need is a cohort definition that would provide some testable result against a given data set, perhaps MIMIC 100. Furthermore, you're welcome to look at the other translation as guidance, and do a pull request, as many of these should be straight-forward enhancements.

@clarkevans
Copy link
Contributor

I've updated the README to discuss this and created an issue template. If this is still unimplemented, could you submit that as a feature request? We would also accept a pull request, but it's important to have test cases.

@clarkevans clarkevans closed this as not planned Won't fix, can't repro, duplicate, stale Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants