<commit_before>from django.db import models
import time


# Create your models here.
class Doctor(models.Model):
    id = models.AutoField(primary_key=True, unique=True)
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def to_dict(self):
        return dict(
            id=self.id,
            first_name=self.first_name,
            last_name=self.last_name,
            created_at=time.mktime(self.created_at.timetuple()),
            updated_at=time.mktime(self.updated_at.timetuple())
        )


class User(models.Model):
    id = models.AutoField(primary_key=True, unique=True)
    doctor = models.ForeignKey('Doctor', on_delete=models.CASCADE, related_name="doctor_users")
    first_name = models.CharField(max_length=30, default="")
    last_name = models.CharField(max_length=30, default="")
    address = models.CharField(max_length=200, default="")
    genders = (
        ('M', 'Male'),
        ('F', 'Female'),
        ('N', 'N/A')
    )
    gender = models.CharField(max_length=1, choices=genders, default=genders[2][0])
    birthday = models.DateField()
    email = models.CharField(max_length=255, default="", unique=True)
    password = models.CharField(max_length=255, default="<PASSWORD>")
    healthcard = models.CharField(max_length=30, default="123")
    is_doctor = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def to_dict(self):
        return dict(
            id=self.id,
            first_name=self.first_name,
            last_name=self.last_name,
            address=self.address,
            gender=self.gender,
            birthday=time.mktime(self.birthday.timetuple()),
            email=self.email,
            password=<PASSWORD>,
            healthcard=self.healthcard,
            doctor=self.doctor.to_dict(),
            created_at=time.mktime(self.created_at.timetuple()),
            updated_at=time.mktime(self.updated_at.timetuple())
        )


class EmergencyContact(models.Model):
    id = models.AutoField(primary_key=True, unique=True)
    user = models.ForeignKey('User', on_delete=models.CASCADE, related_name="user_contacts")
    first_name = models.CharField(max_length=30, default="")
    last_name = models.CharField(max_length=30, default="")
    phone_number = models.CharField(max_length=15, default="")
    relationship = models.CharField(max_length=30, default="")
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def to_dict(self):
        return dict(
            id=self.id,
            user=self.user,
            first_name=self.first_name,
            last_name=self.last_name,
            phone_number=self.phone_number,
            relationship=self.relationship,
            created_at=time.mktime(self.created_at.timetuple()),
            updated_at=time.mktime(self.updated_at.timetuple())
        )


class Allergy(models.Model):
    id = models.AutoField(primary_key=True, unique=True)
    user = models.ForeignKey('User', on_delete=models.CASCADE, related_name="user_allergies")
    name = models.CharField(max_length=255, default="")
    severity_choices = (
        ('S', 'Severe'),
        ('M', 'Mild'),
    )
    severity = models.CharField(max_length=1, choices=severity_choices, default=severity_choices[1][0])
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def to_dict(self):
        return dict(
            id=self.id,
            user=self.user,
            name=self.name,
            severity=self.severity,
            created_at=time.mktime(self.created_at.timetuple()),
            updated_at=time.mktime(self.updated_at.timetuple())
        )


class Prescription(models.Model):
    id = models.AutoField(primary_key=True, unique=True)<commit_msg>Fixed json serialization of allergy<commit_after>from django.db import models
import time


# Create your models here.
class Doctor(models.Model):
    id = models.AutoField(primary_key=True, unique=True)
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def to_dict(self):
        return dict(
            id=self.id,
            first_name=self.first_name,
            last_name=self.last_name,
            created_at=time.mktime(self.created_at.timetuple()),
            updated_at=time.mktime(self.updated_at.timetuple())
        )


class User(models.Model):
    id = models.AutoField(primary_key=True, unique=True)
    doctor = models.ForeignKey('Doctor', on_delete=models.CASCADE, related_name="doctor_users")
    first_name = models.CharField(max_length=30, default="")
    last_name = models.CharField(max_length=30, default="")
    address = models.CharField(max_length=200, default="")
    genders = (
        ('M', 'Male'),
        ('F', 'Female'),
        ('N', 'N/A')
    )
    gender = models.CharField(max_length=1, choices=genders, default=genders[2][0])
    birthday = models.DateField()
    email = models.CharField(max_length=255, default="", unique=True)
    password = models.CharField(max_length=255, default="<PASSWORD>")
    healthcard = models.CharField(max_length=30, default="123")
    is_doctor = models.BooleanField(default=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def to_dict(self):
        return dict(
            id=self.id,
            first_name=self.first_name,
            last_name=self.last_name,
            address=self.address,
            gender=self.gender,
            birthday=time.mktime(self.birthday.timetuple()),
            email=self.email,
            password=self.password,
            healthcard=self.healthcard,
            doctor=self.doctor.to_dict(),
            created_at=time.mktime(self.created_at.timetuple()),
            updated_at=time.mktime(self.updated_at.timetuple())
        )


class EmergencyContact(models.Model):
    id = models.AutoField(primary_key=True, unique=True)
    user = models.ForeignKey('User', on_delete=models.CASCADE, related_name="user_contacts")
    first_name = models.CharField(max_length=30, default="")
    last_name = models.CharField(max_length=30, default="")
    phone_number = models.CharField(max_length=15, default="")
    relationship = models.CharField(max_length=30, default="")
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def to_dict(self):
        return dict(
            id=self.id,
            user=self.user,
            first_name=self.first_name,
            last_name=self.last_name,
            phone_number=self.phone_number,
            relationship=self.relationship,
            created_at=time.mktime(self.created_at.timetuple()),
            updated_at=time.mktime(self.updated_at.timetuple())
        )


class Allergy(models.Model):
    id = models.AutoField(primary_key=True, unique=True)
    user = models.ForeignKey('User', on_delete=models.CASCADE, related_name="user_allergies")
    name = models.CharField(max_length=255, default="")
    severity_choices = (
        ('S', 'Severe'),
        ('M', 'Mild'),
    )
    severity = models.CharField(max_length=1, choices=severity_choices, default=severity_choices[1][0])
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    def to_dict(self):
        return dict(
            id=self.id,
            user=self.user.to_dict(),
            name=self.name,
            severity=self.severity,
            created_at=time.mktime(self.created_at.timetuple()),
            updated_at=time.mktime(self.updated_at.timetuple())
        )


class Prescription(models.Model):
    id = models.AutoField(primary_key=True, unique=True)
{'fraction_non_alphanumeric': 0.1237215033887862, 'fraction_numerical': 0.009611829944547136, 'mean_word_length': 3.203003625064733, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1008368', 'n_tokens_mistral': 2647, 'n_tokens_neox': 2558, 'n_words': 347}