File size: 3,454 Bytes
34acdd0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env python3
"""
Copyright (c) 2020, Carleton University Biomedical Informatics Collaboratory

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""

from typing import List, Optional
from typing_extensions import TypedDict

class ThresholdDict(TypedDict):
    """Represents a hearing threshold (measurement).
    """
    frequency: int
    threshold: int
    ear: str
    masking: bool
    conduction: str
    measurementType: str
    response: bool

class BoundingBox(TypedDict):
    """Represents the dictionary holding the minimum information
    for a bounding box.
    """
    x: int
    y: int
    width: int
    height: int

class AudiogramDict(TypedDict):
    """Represents the dictionary for an audiogram as extracted
    by the Yolo model.
    """
    boundingBox: BoundingBox
    confidence: Optional[float]

class LabelDict(TypedDict):
    """Represents the dictionary for a label as extracted
    by the Yolo model.
    """
    boundingBox: BoundingBox
    value: str
    confidence: Optional[float]

class SymbolDict(TypedDict):
    """Represents the dictionary for a symbol as extracted
    by the Yolo model.
    """
    boundingBox: BoundingBox
    measurementType: str
    confidence: Optional[float]

class CornerDict(TypedDict):
    """Represents a corner, as annotated.
    """
    frequency: int
    threshold: int
    position: TypedDict("PositionDict", { "horizontal": str, "vertical": str })
    x: float
    y: float

class AudiogramAnnotationDict(TypedDict):
    """Represents an audiogram as structured within an annotation.
    """
    confidence: Optional[float]
    correctionAngle: Optional[float]
    boundingBox: BoundingBox
    corners: List[CornerDict]
    labels: List[LabelDict]
    symbols: List[SymbolDict]

class ClaimantProfileDict(TypedDict):
    """Profile of the claimant.
    """
    age: int
    exposure: List[dict] # out of scope for me
    thresholds: List[ThresholdDict]

class CalculationsDict(TypedDict):
    """Values calculated for the claim.
    """
    bestEarPta: float
    correctedBestEarPta: float
    worstEarPta: float
    correctedWorstEarPta: float
    bestEarRabinowitzNotchIndex: Optional[float]
    worstEarRabinowitzNotchIndex: Optional[float]

class HearingLossCriteriaDict(TypedDict):
    """Information related to the hearing loss for the claim.
    Includes different calculated values, etc.
    """
    preliminaryDecisionAvailable: bool
    calculations: CalculationsDict
    eligible: bool
    comment: str
    awardPercentage: float
    reviewNeeded: bool

class MeasurementType(TypedDict):
    """Type of measurement.
    """
    conduction: str
    masking: bool

class SettingsDict(TypedDict):
    """Settings used in computing the eligibility.
    """
    left: TypedDict("EarSettings", { 
        "measurementType": TypedDict("MeasurementType", {
            "conduction": str,
            "masking": bool
        }),
        "ptaFrequencies": List[int]
    })
    right: TypedDict("EarSettings", { 
        "measurementType": TypedDict("MeasurementType", {
            "conduction": str,
            "masking": bool
        }),
        "ptaFrequencies": List[int]
    })

class EligibilityDict(TypedDict):
    """Eligibility information.
    """
    claimantProfile: ClaimantProfileDict
    settings: SettingsDict
    hearingLossCriteria: HearingLossCriteriaDict
    exposureCriteria: dict