Ë
    éBji·  ã                   ó`   — d dl mZmZ d dlmZ d dlZ ej                  e«      Z G d„ d«      Z	y)é    )ÚDictÚAny)ÚAppointmentNc                   ó‚   — e Zd ZdZedeeef   defd„«       Z	edeeef   defd„«       Z
ed„ «       Zededefd„«       Zy	)
ÚAppointmentRepositoryz9
    Repository layer for Appointment DB operations.
    ÚdataÚreturnc                 ó@   — t        j                  j                  di | ¤ŽS )z{
        Create and return an Appointment instance.
        Expects `data` keys to match Appointment model fields.
        © )r   ÚobjectsÚcreate)r   s    ú^/var/www/html/dp2/backend_v2.1/server/apps/appointments/repositories/appointment_repository.pyÚcreate_appointmentz(AppointmentRepository.create_appointment   s   € ô ×"Ñ"×)Ñ)Ñ1¨DÑ1Ð1ó    c                 ó8  — d| d   i}i }dD ]  }|| v sŒ| |   €Œ| |   ||<   Œ |st         j                  d| d   «       dD cg c]	  }||vsŒ|‘Œ }}|rt         j                  d| d   |«       t        j                  j
                  di |¤d|i¤Ž\  }}|S c c}w )zh
        One active appointment per Twilio Call SID.
        Rescheduling updates the same row.
        Útwilio_call_sid)ÚnameÚscheduled_dateÚappointment_phoneÚofftimeÚcompanyÚcallÚbot_typeÚbooking_typez9Update called for appointment %s with no updatable fields)r   r   z5Partial update for appointment %s, missing fields: %sÚdefaultsr   )ÚloggerÚwarningÚinfor   r   Úupdate_or_create)r   Úlookupr   ÚfieldÚfÚmissing_fieldsÚappointmentÚcreateds           r   Úcreate_or_update_by_call_sidz2AppointmentRepository.create_or_update_by_call_sid   sÞ   € ð ˜tÐ$5Ñ6ð
ˆð
 ˆó	
ˆEð ˜Š}  e¡Ñ!8Ø"& u¡+˜’ð	
ñ ÜN‰NØKØÐ&Ñ'ôñ
 &@ÓUÑ%? À1ÈHÒCTš!Ð%?ˆÐUÙÜK‰KØGØÐ&Ñ'Øôô  +×2Ñ2×CÑCñ  
Øñ 
àò 
ÑˆWð
 Ðùò Vs   Á	BÁBc                  óB   — t         j                  j                  d¬«      S )NT)Úcall__isnull)r   r   Úexcluder   r   r   Úget_querysetz"AppointmentRepository.get_querysetF   s   € ä×"Ñ"×*Ñ*¸Ð*Ó=Ð=r   Úappointment_idc                 óf   — t         j                  «       j                  | ¬«      j                  «       S )zW
        Retrieve an Appointment by its ID.
        Returns None if not found.
        )Úid)r   r*   ÚfilterÚfirst)r+   s    r   Ú	get_by_idzAppointmentRepository.get_by_idJ   s/   € ô %×1Ñ1Ó3×:Ñ:Øð ;ó 
ç
‰%‹'ð	r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústaticmethodr   Ústrr   r   r   r&   r*   Úintr0   r   r   r   r   r   	   s’   „ ñð ð2  c¨3 h¡ð 2°Kò 2ó ð2ð ð-¨4°°S°©>ð -¸kò -ó ð-ð^ ñ>ó ð>ð ð #ð ¨+ò ó ñr   r   )
Útypingr   r   Úapps.appointments.modelsr   ÚloggingÚ	getLoggerr1   r   r   r   r   r   Ú<module>r<      s.   ðß Ý 0Û ð 
ˆ×	Ñ	˜8Ó	$€÷Iò Ir   