Contact carries the best-priority mobile and landline Abri lists 🟩

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-06 13:27:59 +00:00
parent 1d3219ca60
commit 1752a6cf10

View file

@ -30,12 +30,18 @@ def _format_appointment_date(appointment_date: date) -> str:
return appointment_date.strftime("%d/%m/%Y")
def _phone_priority(entry: ET.Element) -> Tuple[int, int]:
"""Sort key: lowest numeric priority first; unusable priorities last."""
try:
return (0, int((entry.get("priority") or "").strip()))
except ValueError:
return (1, 0)
def _select_phone_number(entries: List[ET.Element]) -> Optional[str]:
for entry in entries:
number = (entry.text or "").strip()
if number:
return number
return None
usable = [entry for entry in entries if (entry.text or "").strip()]
ranked = sorted(usable, key=_phone_priority) # stable: ties keep document order
return (ranked[0].text or "").strip() if ranked else None
class AbriClient: