I am working on an API using FastAPI that interacts with a Mongo DB via Motor. Our database contains documents on various illnesses such that look like this:
{
"_id": {
"$oid": "6008b21ba1285a480088ff48"
},
"names": ["heart_attack", "myocardial_infarction"],
"umls": ["C0027051"],
"risk_factors": ["smoking", "age < 45", "male", "obesity", "etc"],
"risk_factors_umls": ["C0037369", "CXXXXXXX"],
"symptoms_umls": ["C0008031", "etc."], # ids for symptoms
"is_emergency": true
}
I am looking for the correct MongoDB query syntax (ideally with a small python code example) that given a list of risk factors or symptom ids returns all illness documents containing one or more of these ids or strings.
Most Illnesses have a different amount of symptoms, so the order of the ids varies from document to document.
Since I'm very new to mongoDB I am not sure what the correct query would look like. I tried multiple variations of illness_collection.find()
but so far I haven't been sucessful.
Thank you in advance for your help!