def handle_include(context, phenotype: PhenotypeModel): print('include') # ohdsi_helpers = PhenotypeDefine('OHDSIHelpers', 'include', version='1.0', alias='OHDSI') # include OHDSIHelpers version "1.0" called OHDSI; phenotype_def = None previous = '' for c in context.getChildren(): if previous == 'include': desc = c.getText() phenotype_def = PhenotypeDefine(desc, previous) elif previous == 'called': alias = c.getText() phenotype_def['alias'] = alias elif type(c) == nlpql_parserParser.VersionContext: version = c.getChild(1).getText().strip('"') phenotype_def['version'] = version previous = c.getText() if not phenotype.includes: phenotype.includes = list() phenotype.includes.append(phenotype_def)
def handle_code_system(context, phenotype: PhenotypeModel): print('code system') # codesystem OMOP: "http://omop.org"; # omop = PhenotypeDefine('OMOP', 'codesystem', values=['http://omop.org']) identifier = context.getChild(1) kv = get_identifier_pair(identifier) if type(kv['value']) == list: phenotype_def = PhenotypeDefine(kv['name'], 'codesystem', values=kv['value']) else: vals = list() vals.append(kv['value']) phenotype_def = PhenotypeDefine(kv['name'], 'codesystem', values=vals) if not phenotype.code_systems: phenotype.code_systems = list() phenotype.code_systems.append(phenotype_def)
def handle_phenotype_name(context, phenotype: PhenotypeModel): print('phenotype_name') previous = '' phenotype_def = None for c in context.getChildren(): if previous == 'phenotype': desc = c.getText() phenotype_def = PhenotypeDefine(desc, previous) elif type(c) == nlpql_parserParser.VersionContext: version = c.getChild(1).getText().strip('"') phenotype_def['version'] = version previous = c.getText() phenotype.phenotype = phenotype_def
def handle_cohort(context, phenotype: PhenotypeModel): print('cohort') call = get_pair_method(context.getChild(1)) name = call["name"] library = call["method"]["library"] funct = call["method"]["funct"] arguments = call["method"]["arguments"] named_arguments = call["method"]["named_arguments"] phenotype_def = PhenotypeDefine(name, 'cohort', library=library, funct=funct, arguments=arguments, named_arguments=named_arguments) if not phenotype.cohorts: phenotype.cohorts = list() phenotype.cohorts.append(phenotype_def)
def handle_data_model(context, phenotype: PhenotypeModel): print('data model') previous = '' phenotype_def = None for c in context.getChildren(): if previous == 'datamodel': desc = c.getText() phenotype_def = PhenotypeDefine(desc, previous) elif type(c) == nlpql_parserParser.VersionContext: version = c.getChild(1).getText().strip('"') phenotype_def['version'] = version previous = c.getText() if not phenotype.data_models: phenotype.data_models = list() phenotype.data_models.append(phenotype_def)
def handle_document_set(context, phenotype: PhenotypeModel): print('document set') # documentset ProviderNotes: Clarity.createDocumentList("'Physician' OR 'Nurse' OR 'Note' OR 'Discharge Summary'"); call = get_pair_method(context.getChild(1)) name = call["name"] library = call["method"]["library"] funct = call["method"]["funct"] arguments = call["method"]["arguments"] named_arguments = call["method"]["named_arguments"] phenotype_def = PhenotypeDefine(name, 'documentset', library=library, funct=funct, arguments=arguments, named_arguments=named_arguments) if not phenotype.document_sets: phenotype.document_sets = list() phenotype.document_sets.append(phenotype_def)
def handle_term_set(context, phenotype: PhenotypeModel): print('term set') # termset RigorsTerms: ["Rigors", # "Rigoring", # "Rigours", # "Rigouring", # "Chill", # "Chills", # "Shivers", # "Shivering", # "Teeth chattering"]; # Sepsis = PhenotypeDefine("Sepsis", "termset", values=['Sepsis', 'Systemic infection']) ts = get_pair_array(context.getChild(1)) pd = PhenotypeDefine(ts["name"], "termset", values=ts["array"]) if not phenotype.term_sets: phenotype.term_sets = list() phenotype.term_sets.append(pd)
def handle_value_set(context, phenotype: PhenotypeModel): print('value set') # Sepsis = PhenotypeDefine('Sepsis', 'valueset', library='OHDSI', # funct='getConceptSet', # arguments=['assets/Sepsis.json']) # valueset RigorsConcepts:OHDSI.getConceptSet("assets/RigorsConcepts.json"); call = get_pair_method(context.getChild(1)) name = call["name"] library = call["method"]["library"] funct = call["method"]["funct"] arguments = call["method"]["arguments"] phenotype_def = PhenotypeDefine(name, 'valueset', library=library, funct=funct, arguments=arguments) if not phenotype.value_sets: phenotype.value_sets = list() phenotype.value_sets.append(phenotype_def)