from django.db import models

class Hospital(models.Model):
    STATES_CHOICES = [
        ('BW', 'Baden-Württemberg'),
        ('BY', 'Bayern'),
        ('BE', 'Berlin'),
        ('BB', 'Brandenburg'),
        ('HB', 'Bremen'),
        ('HH', 'Hamburg'),
        ('HE', 'Hessen'),
        ('MV', 'Mecklenburg-Vorpommern'),
        ('NI', 'Niedersachsen'),
        ('NW', 'Nordrhein-Westfalen'),
        ('RP', 'Rheinland-Pfalz'),
        ('SL', 'Saarland'),
        ('SN', 'Sachsen'),
        ('ST', 'Sachsen-Anhalt'),
        ('SH', 'Schleswig-Holstein'),
        ('TH', 'Thüringen'),
    ]

    name = models.CharField(max_length=255)
    state = models.CharField(max_length=2, choices=STATES_CHOICES)
    city = models.CharField(max_length=100)
    address = models.TextField(blank=True)
    website = models.URLField(blank=True)

    def __str__(self):
        return f"{self.name} ({self.get_state_display()})"

    class Meta:
        verbose_name_plural = "Hospitals"

class DepartmentChief(models.Model):
    DEPARTMENT_CHOICES = [
        ('AN', 'Anesthesia'),
        ('NU', 'Nursing'),
        ('IC', 'Intensive Care'),
        ('SU', 'Surgery'),
        ('IM', 'Internal Medicine'),
        ('PE', 'Pediatrics'),
        ('GY', 'Gynecology'),
        ('OT', 'Other'),
    ]

    hospital = models.ForeignKey(Hospital, on_delete=models.CASCADE, related_name='chiefs')
    name = models.CharField(max_length=255)
    title = models.CharField(max_length=100, help_text="e.g. Chief of Medicine, Head Nurse")
    department = models.CharField(max_length=2, choices=DEPARTMENT_CHOICES)
    email = models.EmailField()

    def __str__(self):
        return f"{self.name} - {self.get_department_display()} at {self.hospital.name}"