Skip to content

Instantly share code, notes, and snippets.

View alopezo's full-sized avatar

Alejandro Lopez Osornio alopezo

  • SNOMED International
  • Montevideo, Uruguay
View GitHub Profile
import pandas as pd
import json
import uuid
import tarfile
import os
# Load the Excel file
file_path = '/Users/alejandrolopezosornio/Library/Mobile Documents/com~apple~CloudDocs/Documents/2023/SNOMED/snomed-scripts/xshare/001_2024-02-23_LB and MB_contributed data to CDISC.xlsx'
excel_data = pd.ExcelFile(file_path)
import pandas as pd
import os
import warnings
warnings.simplefilter("ignore", UserWarning)
# UPDATE ALL FILES PATHS BEFORE RUNNING THE SCRIPT
# Load map spreadsheet
map_file_path = 'Downloads/Map of Common Diseases_1.xlsx'
@alopezo
alopezo / entity_extractor.py
Created July 26, 2023 17:20
A python script that uses AI to analyze clinical texts and extract SNOMED concepts using Llama2 LLM and a FHIR Terminology Server
from llama_cpp import Llama
import json
import time
import re
import fhir_api
# ANSI escape sequences for text colors
COLOR_RED = "\033[91m"
COLOR_GREEN = "\033[92m"
COLOR_YELLOW = "\033[93m"
@alopezo
alopezo / SNOMED API Match.js
Last active October 12, 2022 15:11
SNOMED API Match for Google App Script
function searchInSnomed(term, module, version, ecl) {
const config = {
muteHttpExceptions: true
};
const url = `https://snowstorm.ihtsdotools.org/fhir/ValueSet/$expand?url=http://snomed.info/sct/${module}/version/${version}?fhir_vs=ecl/${encodeURIComponent(ecl)}&count=20&offset=0&filter=${term}`;
var response = UrlFetchApp.fetch(url, config);
let responseObject = JSON.parse(response.getBlob().getDataAsString());
let result = "";
if (responseObject && responseObject.expansion && responseObject.expansion.contains) {
let firstMatch = responseObject.expansion.contains[0];
/**
* Created by alo on 2/20/17.
*/
var fs = require('fs'),
byline = require('byline');
function convertDate(epoch) {
if (epoch) {
var myDate = new Date(epoch*1000);
return myDate.toGMTString();
@alopezo
alopezo / chessApiLookup.js
Last active October 15, 2017 12:03
Creates a list of users with details
/**
* Created by alo on 10/15/17.
*/
var getJSON = require('get-json');
var sem = require('semaphore')(1);
var https = require('https');
getJSON('https://api.chess.com/pub/country/AR/players', function(error, response){
if (error) {
console.log(error);
@alopezo
alopezo / disposition-groupers-modification.sql
Created June 29, 2017 12:10
This script modifies the stated relationships on the Substances hierarchy, transforming primitive grouper concepts into Sufficiently Defined concepts, with proximal primitive parents and "has disposition" attributes
/*
*
* Script to modify the hierarchy of substances according to the grouper concepts and disposition values
*
* Author: Alejandro Rodriguez
*
* Requirements:
* - RF2 snapshot
* - List of corresponding grouper concepts and dispositions [grouperId dispositionId]
* - List of new relationship ids (~ 10000) [id partitionId namespace assigned] with assigned column in 0