@@ -93,8 +93,10 @@ async def check_interactions(self, drugs: list[str]) -> list[dict[str, Any]]:
9393 # Using unquoted search for the second drug to allow
9494 # partial/text matches
9595 queries = [
96- f'(openfda.brand_name:"{ d1 } " OR openfda.generic_name:"{ d1 } ") AND { d2 } ' ,
97- f'(openfda.brand_name:"{ d2 } " OR openfda.generic_name:"{ d2 } ") AND { d1 } '
96+ f'(openfda.brand_name:"{ d1 } " OR '
97+ f'openfda.generic_name:"{ d1 } ") AND { d2 } ' ,
98+ f'(openfda.brand_name:"{ d2 } " OR '
99+ f'openfda.generic_name:"{ d2 } ") AND { d1 } '
98100 ]
99101 for q in queries :
100102 try :
@@ -106,9 +108,11 @@ async def check_interactions(self, drugs: list[str]) -> list[dict[str, Any]]:
106108 result = data ["results" ][0 ]
107109 # Try to get specific interaction text, fallback to warnings
108110 evidence = result .get ("drug_interactions" , ["" ])[0 ] or \
109- result .get ("warnings" , ["No specific text found." ])[0 ]
111+ result .get ("warnings" ,
112+ ["No specific text found." ])[0 ]
110113 short_evidence = (
111- evidence [:500 ] + "..." if len (evidence ) > 500 else evidence
114+ evidence [:500 ] + "..." \
115+ if len (evidence ) > 500 else evidence
112116 )
113117
114118 interactions .append ({
@@ -135,8 +139,10 @@ def check_interactions_sync(self, drugs: list[str]) -> list[dict[str, Any]]:
135139 for j in range (i + 1 , len (drugs )):
136140 d1 , d2 = drugs [i ], drugs [j ]
137141 queries = [
138- f'(openfda.brand_name:"{ d1 } " OR openfda.generic_name:"{ d1 } ") AND { d2 } ' ,
139- f'(openfda.brand_name:"{ d2 } " OR openfda.generic_name:"{ d2 } ") AND { d1 } '
142+ f'(openfda.brand_name:"{ d1 } " OR '
143+ f'openfda.generic_name:"{ d1 } ") AND { d2 } ' ,
144+ f'(openfda.brand_name:"{ d2 } " OR '
145+ f'openfda.generic_name:"{ d2 } ") AND { d1 } '
140146 ]
141147 for q in queries :
142148 try :
@@ -147,9 +153,11 @@ def check_interactions_sync(self, drugs: list[str]) -> list[dict[str, Any]]:
147153 data = response .json ()
148154 result = data ["results" ][0 ]
149155 evidence = result .get ("drug_interactions" , ["" ])[0 ] or \
150- result .get ("warnings" , ["No specific text found." ])[0 ]
156+ result .get ("warnings" ,
157+ ["No specific text found." ])[0 ]
151158 short_evidence = (
152- evidence [:500 ] + "..." if len (evidence ) > 500 else evidence
159+ evidence [:500 ] + "..." \
160+ if len (evidence ) > 500 else evidence
153161 )
154162
155163 interactions .append ({
0 commit comments