@@ -304,7 +304,16 @@ const PatientSummary = ({
304304 setLoading ( true ) ;
305305
306306 try {
307- const data = await fetchRiskDataWithSources ( medication , source ) ;
307+ // Map source based on patient's diagnosis
308+ let apiSource : "include" | "diagnosis" | "diagnosis_depressed" = source ;
309+ if ( source === "diagnosis" && patientInfo . Diagnosis === "Depressed" ) {
310+ apiSource = "diagnosis_depressed" ;
311+ }
312+
313+ const data = await fetchRiskDataWithSources ( medication , apiSource ) ;
314+ console . log ( "Risk data received for" , medication , "with source" , apiSource , ":" , data ) ;
315+ console . log ( "Sources array:" , data . sources ) ;
316+ console . log ( "Sources length:" , data . sources ?. length ) ;
308317 setRiskData ( data as RiskData ) ;
309318 } catch ( error ) {
310319 console . error ( "Error fetching risk data: " , error ) ;
@@ -331,7 +340,13 @@ const PatientSummary = ({
331340 setLoading ( true ) ;
332341
333342 try {
334- const data = await fetchRiskDataWithSources ( medication , source ) ;
343+ // Map source based on patient's diagnosis
344+ let apiSource : "include" | "diagnosis" | "diagnosis_depressed" = source ;
345+ if ( source === "diagnosis" && patientInfo . Diagnosis === "Depressed" ) {
346+ apiSource = "diagnosis_depressed" ;
347+ }
348+
349+ const data = await fetchRiskDataWithSources ( medication , apiSource ) ;
335350 setRiskData ( data as RiskData ) ;
336351 } catch ( error ) {
337352 console . error ( "Error fetching risk data: " , error ) ;
@@ -605,7 +620,7 @@ const PatientSummary = ({
605620 < div className = "flex-row justify-between py-6 border-b border-gray-900/10 md:flex" >
606621 < div className = "flex w-full md:p-0" >
607622 < dt className = "w-1/2 text-sm font-medium leading-6 text-gray-900" >
608- Current State:
623+ Current or Most recent state
609624 </ dt >
610625 < dd className = "text-sm leading-6 text-gray-700 sm:col-span-2 sm:mt-0" >
611626 { patientInfo . Diagnosis }
0 commit comments