From f5788051f7c5718cbf708df573d66932efdb1e4c Mon Sep 17 00:00:00 2001 From: will king Date: Tue, 31 Jan 2023 17:01:15 -0800 Subject: [PATCH] removed (reasonably successful) attempt at using API. I favor migrading db tables --- RxMix/RxMixInABox.py | 56 -------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 RxMix/RxMixInABox.py diff --git a/RxMix/RxMixInABox.py b/RxMix/RxMixInABox.py deleted file mode 100644 index 7980097..0000000 --- a/RxMix/RxMixInABox.py +++ /dev/null @@ -1,56 +0,0 @@ -import requests -from abc import ABC, abstractmethod -from dataclasses import dataclass - -BASE_URL = "http://LOCALHOST:4000/REST" -FORMAT = '.json' - -@dataclass -class RxCui(): - id: str - - def get_atc_class(self): - pass - def get_brandnames(self): - pass - - - - -def FindRxcuiByString(name: str, **kwargs) -> RxCui: - ''' - Find a RxCUI by string based on a string - Defaults to searching RxNorm (i.e. drugs) using a best match option - ''' - - url = BASE_URL + "/rxcui" + FORMAT - query = {'allsrc':0, 'srclist':'RXNORM', 'search':2} | kwargs | {'name':name} - r = requests.get(url, params=query) - - #extract RxCUIs - return [RxCui(x) for x in r.json()['idGroup']['rxnormId']] - -def get_all_properties(rxcui_list: RxCui,*prop_category): - ''' - This is used to query for properties - ''' - for rxcui in rxcui_list: - url = BASE_URL + "/rxcui/" + rxcui.id + "/allProperties" + FORMAT - r = requests.get(url, params={"prop": prop_category}) - j = r.json() - yield j - -def get_brands_from_ingredients(rxcui: RxCui): - ''' - This is used to query for properties - ''' - url = BASE_URL + "/brands" + FORMAT - r = requests.get(url, params={"ingredientids": rxcui.id}) - j = r.json() - - return [ AssociatedBrand(x,rxcui) for x in j['brandGroup']['conceptProperties']] - -class AssociatedBrand(): - def __init__(self,brand,ingredient: RxCui): - self.ingredient_rxcui = ingredient - self.brand_rxcui = RxCui(brand['rxcui']) \ No newline at end of file