
    jj                    p   d Z ddlmZ ddlmZ ddlmZmZmZ  G d de      Z	ed   Z
ed   Zed	   Z G d
 de	      Z G d de	      Z G d de      Z G d de      Zed   Z G d de      Z G d de      Zed   Z G d de      Z G d de	      Z G d de      Zed   Zed   Zed    Z G d! d"e	      Z G d# d$e      Zed%   Zed&   Z G d' d(e	      Z G d) d*e	      Z  G d+ d,e	      Z! G d- d.e      Z" G d/ d0e      Z#ed1   Z$ G d2 d3e      Z% G d4 d5e	      Z& G d6 d7e	      Z' G d8 d9e	      Z(y:);u  Pydantic models for the interpret service.

The canonical source is contracts/dist/schema.json (TypeScript Zod). We
DON'T regenerate Pydantic models from it at runtime — instead, a developer
runs `scripts/regenerate.sh` (or the datamodel-codegen invocation in the
README) after schema changes. For Phase 1 we work with a thin Pydantic
hand-written model that mirrors the Zod schema enough to validate output.

Keeping this hand-written means we own the Python shape; if the codegen
ever drifts or fails we still have a working service.
    )annotations)Literal)	BaseModelField
ConfigDictc                       e Zd Z edd      Zy)_StrictforbidF)extrafrozenN)__name__
__module____qualname__r   model_config     H/var/www/adampowell.pro/apps/ekg-tutor/interpret/src/schemas/__init__.pyr	   r	      s    HU;Lr   r	   )lowmediumhigh)goodmarginalpoor)IIIIIIaVRaVLaVFV1V2V3V4V5V6rhythm_stripc                  :    e Zd ZU ded<   ded<   dZded<   ded	<   y)
MeasurementfloatvaluestrunitNztuple[float, float] | Nonenormal_rangez+Literal['normal', 'borderline', 'abnormal']interpretation)r   r   r   __annotations__r-   r   r   r   r(   r(   !   s    L
I/3L,3??r   r(   c                  |    e Zd ZU  edd      Zded<    edd      Zded<   ded	<   d
ed<    edd      Zded<   y)_Section   i  
min_length
max_lengthr+   findingi  	reasoning
Confidence
confidence
list[Lead]leads_to_examinei  teaching_pointN)r   r   r   r   r6   r/   r7   r<   r   r   r   r1   r1   (   sA    A#6GS6aD9Is9  1>NC>r   r1   c                  &    e Zd ZU ded<   dZded<   y)RateSectionr(   measurementNzMeasurement | Noneatrial_rate)r   r   r   r/   r@   r   r   r   r>   r>   0   s    &*K#*r   r>   c                  "    e Zd ZU ded<   ded<   y)RhythmSectionr+   	diagnosiszbool | NoneregularNr   r   r   r/   r   r   r   rB   rB   5   s    Nr   rB   )normalleft_deviationright_deviationextremeindeterminatec                  "    e Zd ZU ded<   ded<   y)AxisSectionr(   r?   AxisCategorycategoryNrE   r   r   r   rL   rL   =   s    r   rL   c                      e Zd ZU ded<   y)IntervalSectionr(   r?   NrE   r   r   r   rP   rP   B   s    r   rP   )bazett
fridericia
framinghamc                  "    e Zd ZU ded<   ded<   y)
QTcSectionr(   r?   CorrectionFormulacorrection_formulaNrE   r   r   r   rU   rU   I   s    ))r   rU   c                  6    e Zd ZU ded<   ded<   ded<   ded<   y)IntervalsSectionrP   prqrsqtrU   qtcNrE   r   r   r   rY   rY   N   s    		Or   rY   c                      e Zd ZU ded<   y)PWaveSection	list[str]abnormalitiesNrE   r   r   r   r_   r_   U   s    r   r_   )nonerbbblbbbincomplete_rbbbincomplete_lbbbnonspecific_ivcd)rb   lafblpfbbifascicular)anteriorinferiorlateralseptal	posteriorrb   c                  ,    e Zd ZU ded<   ded<   ded<   y)PathologicQWavesboolpresentr:   leadszInfarctTerritory | None	territoryNrE   r   r   r   rq   rq   b   s    M&&r   rq   c                  ,    e Zd ZU ded<   ded<   ded<   y)QRSMorphologySectionBundleBranchBlockbundle_branch_blockFascicularBlockfascicular_blockrq   pathologic_q_wavesNrE   r   r   r   rw   rw   h   s    **%%((r   rw   )concaveconvex
horizontal)r   downsloping	upslopingc                  L    e Zd ZU ded<   ded<   dZded<   dZded	<   dZd
ed<   y)STElevationrr   rs   r:   rt   Nzfloat | Nonemagnitude_mmzSTMorphology | None
morphology
str | Noneru   )r   r   r   r/   r   r   ru   r   r   r   r   r   r   s,    M!%L,%&*J#* Iz r   r   c                  0    e Zd ZU ded<   ded<   dZded<   y)STDepressionrr   rs   r:   rt   NzSTDepressionMorphology | Noner   )r   r   r   r/   r   r   r   r   r   r   z   s    M04J-4r   r   c                  ,    e Zd ZU ded<   ded<   ded<   y)TWaveChangesr:   inverted_leadsrr   peakedflatNrE   r   r   r   r   r      s    L
Jr   r   c                  ,    e Zd ZU ded<   ded<   ded<   y)
STTSectionr   st_elevationr   st_depressionr   t_wave_changesNrE   r   r   r   r   r      s      r   r   c                  @    e Zd ZU ded<   ded<   ded<   ded<   ded<   y)	ChamberSectionrr   lvhrvhla_enlargementra_enlargementr`   criteria_metNrE   r   r   r   r   r      s    	I	Ir   r   )rb   first_degreemobitz_i	mobitz_ii
high_gradecompletec                  ,    e Zd ZU ded<   ded<   ded<   y)ConductionSectionAVBlockav_blockrr   preexcitationpacedNrE   r   r   r   r   r      s    Kr   r   c                  ^    e Zd ZU  edd      Zded<   ded<   ded<   ded	<   ded
<   ded<   y)FinalSynthesisr2      r3   r+   one_line_summaryprimary_diagnosisr`   secondary_findingsdifferentialclinical_significance_educationr8   overall_confidenceN)r   r   r   r   r   r/   r   r   r   r   r      s2    !Q3?c?!!%((""r   r   c                      e Zd ZU ded<   y)CannotInterpretr+   reasonNrE   r   r   r   r   r      s    Kr   r   c                      e Zd ZU ded<   ded<   dZded<   ded	<   d
ed<   ded<   ded<   ded<   ded<   ded<   ded<   ded<   ded<    edd      Zded <    edd!      Zd"ed#<   ded$<   dZd%ed&<   y)'InterpretationzLiteral['1.0']schema_versionImageQualityimage_qualityNr   image_quality_notesr>   raterB   rhythmrL   axisrY   	intervalsr_   p_wave_morphologyrw   qrs_morphologyr   st_t_changesr   chamber_enlargementr   conduction_abnormalitiesr   final_synthesisr2      r3   r`   teaching_pearls)geleintdifficulty_estimateconcepts_illustratedzCannotInterpret | Nonecannot_interpret)	r   r   r   r/   r   r   r   r   r   r   r   r   r   r      s    ""&**

##((''//##!&!!BOYB$a00##/3,3r   r   N))__doc__
__future__r   typingr   pydanticr   r   r   r	   r8   r   Leadr(   r1   r>   rB   rM   rL   rP   rV   rU   rY   r_   rx   rz   InfarctTerritoryrq   rw   STMorphologySTDepressionMorphologyr   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s  
 #  1 1<i < ,-
12@' @?w ?+( +
H 
 `a( 
h  @A * *
w 8  T  @AD 
'w ')8 ) 89 !IJ !' !57 57 ! !X  M
 #W #g 4W 4r   