from components.mongoconnection import provideClient mc=provideClient() db=mc["askmydoc_db"] coll=db["askmydoc_col"] def GetDeepDive(owner,typeofmsg,files): match typeofmsg: case "legal": document = coll.find_one({"owner": owner}) if document is None or "deepdive" not in document or len(document["deepdive"]) == 0: return {"dive":[]} else: filtered=[] for msg in document["deepdive"]: if msg["type"] == typeofmsg and any(f in files for f in msg["files"]): filtered.append(msg) return {"dive":filtered} case "medical": document = coll.find_one({"owner": owner}) if document is None or "deepdive" not in document or len(document["deepdive"]) == 0: return {"dive":[]} else: filtered=[] for msg in document["deepdive"]: if msg["type"] == typeofmsg and any(f in files for f in msg["files"]): filtered.append(msg) return {"dive":filtered} case "research": document = coll.find_one({"owner": owner}) if document is None or "deepdive" not in document or len(document["deepdive"]) == 0: return {"dive":[]} else: filtered=[] for msg in document["deepdive"]: if msg["type"] == typeofmsg and any(f in files for f in msg["files"]): filtered.append(msg) return {"dive":filtered}