Defining Dentalstatus as a class in python
I may have gone way too far on the basics here. But this would be what I would go for. I am truly sorry for not finding a better way to deal with the problem of the patient's teeth being a big dictionary.
from dataclasses import dataclass
from typing import Optional
teeth = {
18: 'd',
17: 'c',
16: 'c',
15: 'c',
14: 'h',
13: 'd',
12: 'c',
11: 'h',
}
dental_catalog = {
'c': 'crown',
'h': 'healthy',
'd': 'decayed'
}
@dataclass
class Patient:
name: Optional[str]
id: int
dental_health: dict
health_plan: str
exists: bool
def __post_init__(self):
new_dental_health = {}
for key, value in teeth.items():
new_dental_health[key] = dental_catalog[value]
self.dental_health = new_dental_health
patient_one = Patient(name='John', id=1, dental_health=teeth, health_plan='A', exists=True)
print(patient_one.dental_health)
This prints
{18: 'decayed', 17: 'crown', 16: 'crown', 15: 'crown', 14: 'healthy', 13: 'decayed', 12: 'crown', 11: 'healthy'}