diff --git a/src/backend/app/api_v1/endpoints/appointments.py b/src/backend/app/api_v1/endpoints/appointments.py index 6ff9b2e..00ab0a8 100644 --- a/src/backend/app/api_v1/endpoints/appointments.py +++ b/src/backend/app/api_v1/endpoints/appointments.py @@ -11,7 +11,8 @@ from dotenv import load_dotenv from fastapi import APIRouter, BackgroundTasks, File, Header, HTTPException, UploadFile from fastapi.responses import JSONResponse -from llama_index.core import SimpleDirectoryReader, download_loader +from llama_index.core import SimpleDirectoryReader +from llama_index.readers.s3 import S3Reader from openai import AsyncOpenAI, OpenAI from psycopg2.extensions import connection from pydantic import BaseModel, Field @@ -70,7 +71,6 @@ aws_secret_access_key=AWS_SECRET_ACCESS_KEY, region_name=AWS_REGION, ) -S3Reader = download_loader("S3Reader") class AppointmentAnalysis: diff --git a/src/backend/app/db/nosql_db.py b/src/backend/app/db/nosql_db.py index be6bfd9..c5b1a45 100644 --- a/src/backend/app/db/nosql_db.py +++ b/src/backend/app/db/nosql_db.py @@ -152,60 +152,3 @@ def get_relevant_providers( # Perform the query results = provider_collection.find(query) return list(results) - - -if __name__ == "__main__": - - # Establish connection - client = MongoClient("mongodb://localhost:27017/") - db = client["wilson_ai"] - providers = db.providers - - # Example document that will come in - # note that the document 'schema' will contain a list of locations and insurances but on any given - # update we will just be providing one from the incoming document - provider_info = { - # "npi": "1447331368", - "first_name": "Christine", - "last_name": "Corriveau", - "degree": "MD", - "email": None, - "phone_number": None, - "specialty": "PEDIATRIC", - # more complex info - "location": { - "name": "Children's National Hospital", - "street": "111 Michigan Ave NW", - "city": "WASHINGTON", - "state": "DC", - "zip_code": "20010-2978", - "coordinates": { - "lat": 40.766668, - "long": -73.9814608, - }, - }, - } - - # # # Inserting a document - # # inserted_id = providers.insert_one(provider_info).inserted_id - # # print("Inserted physician with ID:", inserted_id) - # modified_count = upsert_provider(providers, provider_info) - - patient_info = {"lat": 40.766668, "lng": -73.9814608, "insurance_id": 3} - - # # Fetching a document - # # doc = providers.find_one({"specialties": 'PCP', "insurances.id": patient_info["insurance_id"]}) # , "insurances.insurance_id": patient_info["insurance_id"] - # # pprint.pprint(doc) - # results = get_relevant_providers(providers, patient_info, "PCP") - # print(results) - # for result in results: - # providers.update_one( - # {"npi": "1609958305"}, - # {"$set": {"specialties": ["PCP"]}}, - # ) - pprint.pprint( - providers.find_one( - {"npi": "1609958305"}, - {"first_name": 1, "last_name": 1, "specialties": 1, "_id": 0}, - ) - ) diff --git a/src/backend/app/db/relational_db.py b/src/backend/app/db/relational_db.py index fbd2740..5eb06f4 100644 --- a/src/backend/app/db/relational_db.py +++ b/src/backend/app/db/relational_db.py @@ -547,20 +547,3 @@ def authenticate_user(conn: connection, email: str, password: str) -> Dict[str, return False return user - - -if __name__ == "__main__": - params = { - "user_id": 1, - "provider_id": "1568424935", - "filename": "data", - "summary": "The patient has been experiencing a chronic cough for three years, associated with symptoms like throat clearing, intermittent dry cough, recurrent heartburn, postnasal drip, and chest tightness during physical activity. Despite previous treatments including Albuterol, Astelin spray, and Prevacid, the cough has persisted. Current recommendations include using Fluticasone spray, Nexium 40 mg daily for two months, and consultations with Allergy and Gastroenterology specialists.", - "appointment_datetime": "2023-09-26 11:30", - "follow_ups": '{"tasks": [{"task": "Consult Allergy and GI specialists."}, {"task": "AMB REF to Allergy & Clinical Immunology."}, {"task": "AMB REF to Gastroenterology."}]}', - "perscriptions": '{"drugs": [{"technical_name": "esomeprazole", "brand_name": "NEXIUM", "instructions": "Take 1 capsule by mouth every morning before breakfast."}, {"technical_name": "fluticasone propionate", "brand_name": "FLONASE", "instructions": "2 sprays in each nostril once daily."}, {"technical_name": "naproxen", "brand_name": "NAPROSYN", "instructions": "Take 1 tablet by mouth every 12 hours as needed. Stop if GI upset."}, {"technical_name": "azelastine", "brand_name": "ASTELIN", "instructions": "USE NASAL SPRAY AS DIRECTED."}, {"technical_name": "trazodone", "brand_name": "DESYREL", "instructions": "TAKE 1 TO 2 TABLETS BY MOUTH EVERY DAY AT BEDTIME AS NEEDED FOR INSOMNIA."}]}', - } - conn = create_connection() - try: - print(set_prescription_status(conn, 1, False)) - except Exception as e: - raise e diff --git a/src/backend/app/db/vector_db.py b/src/backend/app/db/vector_db.py index d5e859d..8a982d1 100644 --- a/src/backend/app/db/vector_db.py +++ b/src/backend/app/db/vector_db.py @@ -101,17 +101,6 @@ def structure_context(context: Dict[str, Any]) -> str: return "\n".join(df["formatted_row"].to_list()) -# def build_index(embed_model: Any) -> VectorStoreIndex: -# db = chromadb.PersistentClient(path=DB_PATH) -# chroma_collection = db.get_or_create_collection(COLLECTION) -# vector_store = ChromaVectorStore(chroma_collection=chroma_collection) -# index = VectorStoreIndex.from_vector_store( -# vector_store, -# embed_model=embed_model, -# ) -# return index - - def query_documents(query: str, user_id: int, index: VectorStoreIndex) -> Response: """query vector db filtering based off user_id in metadata""" query_engine = index.as_query_engine( @@ -141,16 +130,3 @@ def query_documents(query: str, user_id: int, index: VectorStoreIndex) -> Respon chroma_collection = db.get_or_create_collection( COLLECTION, embedding_function=EMBED_MODEL ) - # query = "What diagnosis would explain my symptoms?" - # context = get_context( - # query, 1, chroma_collection - # ) - # organized_context = structure_context(context) - # rqt = OAIRequest( - # system_msg=CHAT_W_DATA_SYS_MSG, - # user_msg=CHAT_W_DATA_USER_MSG.format( - # query, organized_context - # ), - # ) - # response = asyncio.run(a_send_rqt_chat(client, rqt)) - # pprint(response)