@@ -869,9 +869,12 @@ def format_appointments(appointments: list[dict[str, Any]]) -> str:
869869 messages = []
870870 for appointment in appointments :
871871 date = appointment .get ("appointmentDate" , "N/A" )
872- clinic = appointment .get ("clinic" , {}).get ("name" , "N/A" )
873- doctor = appointment .get ("doctor" , {}).get ("name" , "N/A" )
874- specialty = appointment .get ("specialty" , {}).get ("name" , "N/A" )
872+ clinic_info = appointment .get ("clinic" , {}) or {}
873+ clinic = clinic_info .get ("name" , "N/A" )
874+ doctor_info = appointment .get ("doctor" , {}) or {}
875+ doctor = doctor_info .get ("name" , "N/A" )
876+ specialty_info = appointment .get ("specialty" , {}) or {}
877+ specialty = specialty_info .get ("name" , "N/A" )
875878 doctor_languages = appointment .get ("doctorLanguages" , [])
876879 languages = (
877880 ", " .join ([lang .get ("name" , "N/A" ) for lang in doctor_languages ])
@@ -946,9 +949,12 @@ def display_appointments(appointments: list[dict[str, Any]]) -> None:
946949 log .info ("--------------------------------------------------" )
947950 for appointment in appointments :
948951 date = appointment .get ("appointmentDate" , "N/A" )
949- clinic = appointment .get ("clinic" , {}).get ("name" , "N/A" )
950- doctor = appointment .get ("doctor" , {}).get ("name" , "N/A" )
951- specialty = appointment .get ("specialty" , {}).get ("name" , "N/A" )
952+ clinic_info = appointment .get ("clinic" , {}) or {}
953+ clinic = clinic_info .get ("name" , "N/A" )
954+ doctor_info = appointment .get ("doctor" , {}) or {}
955+ doctor = doctor_info .get ("name" , "N/A" )
956+ specialty_info = appointment .get ("specialty" , {}) or {}
957+ specialty = specialty_info .get ("name" , "N/A" )
952958 doctor_languages = appointment .get ("doctorLanguages" , [])
953959 languages = (
954960 ", " .join ([lang .get ("name" , "N/A" ) for lang in doctor_languages ])
0 commit comments