Skip to content

Instantly share code, notes, and snippets.

View jhajagos's full-sized avatar

Janos Hajagos jhajagos

View GitHub Profile
@jhajagos
jhajagos / evaluate_ohnlp_pipeline_run.sql
Created February 25, 2022 13:40
Queries to evaluate OHNLP run
--Queries written against PostGreSQL; queries should be adaptable to other SQL DIALECTS
--OPTIONAL: indicates that query uses additional data stored in OHDSI
--ADVANCED: indicates uses PostGreSQL specific syntax/functions which would need to be rewritten
--Author: Janos Hajagos
--Set the search path
set search_path to sbm_covid19_documents, sbm_covid19_hi_cdm_build;
--Get the count of notes
import pandas as pd
df = pd.DataFrame([{ "trajectory_number" : '1' , "trajectory_type" : "AKI" , "crossing_time_in_seconds" : 150 },
{ "trajectory_number" : '2' , "trajectory_type" : "AKI" , "crossing_time_in_seconds" : 800 },
{ "trajectory_number" : '3' , "trajectory_type" : "AKI" , "crossing_time_in_seconds" : 500 },
{ "trajectory_number" : '4' , "trajectory_type" : "Sepsis" , "crossing_time_in_seconds" : 1000 },
{ "trajectory_number" : '5' , "trajectory_type" : "Sepsis" , "crossing_time_in_seconds" : 1243 },
{ "trajectory_number" : '6' , "trajectory_type" : "Sepsis" , "crossing_time_in_seconds" : 1300 },
{ "trajectory_number" : '7' , "trajectory_type" : "Pneumonia" , "crossing_time_in_seconds" : 2304 },
{ "trajectory_number" : '8' , "trajectory_type" : "Pneumonia" , "crossing_time_in_seconds" : 2305 }
])
import argparse
import csv
import json
import pathlib
import sqlalchemy as sa
def write_delimited_file(cursor, file_name, delimiter):
if delimiter == ",":
file_name = str(file_name) + ".csv"
@jhajagos
jhajagos / make_cleaned_nlp_files_for_n3_submission.py
Created March 29, 2021 21:39
script to extract note and note_nlp tables
import argparse
import csv
import json
import pathlib
import sqlalchemy as sa
def write_delimited_file(cursor, file_name, delimiter):
if delimiter == ",":
file_name = str(file_name) + ".csv"

Example of an OHDSI database for training

age sex_mf resting_blood_pressure serum_cholesterol_mg_dl maximum_heart_rate_achieved oldpeak_st_depression_induced_relative_to_rest slope_of_peak_exercise_st_segment number_of_major_vessels_colored_by_fluoroscopy chest_pain_type fasting_blood_sugar_gt_120_mg_dl_yn exercise_induced_angina_yn thal absence_or_presence_heart_disease_yn
70 M 130 322 109 2.4 2 3 asymptomatic N N normal Y
67 F 115 564 160 1.6 2 0 non-anginal pain N N reversible defect N
57 M 124 261 141 0.3 1 0 atypical angina N N reversible defect Y
64 M 128 263 105 0.2 2 1 asymptomatic N Y reversible defect N
74 F 120 269 121 0.2 1 1 atypical angina N Y normal N
65 M 120 177 140 0.4 1 0 asymptomatic N N reversible defect N
56 M 130 256 142 0.6 2 1 non-anginal pain Y Y fixed defect Y
59 M 110 239 142 1.2 2 1 asymptomatic N Y reversible defect Y
60 M 140 293 170 1.2 2 2 asymptomatic N N reversible defect Y
@jhajagos
jhajagos / gist:7798698
Last active December 30, 2015 07:49
Randomize word order and random letter ordering for spelling HW
words = ["best","guest","crest","question","yesterday","now","people","use","water", "way"]
import random
import itertools
def randomize_word(word):
x = list(itertools.permutations(word))
w = x[random.randint(0,len(x)-1)]
return "".join(w)
def randomize_words_and_order(words):