# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#   * Rearrange models' order
#   * Make sure each model has one field with primary_key=True
#   * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior
#   * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models
from django.db.models.deletion import DO_NOTHING
from digiMED import settings


class Basicmetabolismpanel(models.Model):
    id = models.AutoField(primary_key=True)
    pid = models.ForeignKey('Patient', on_delete=models.CASCADE, db_column='PID', blank=True, null=True)  # Field name made lowercase.
    date = models.DateField(auto_now=False, auto_now_add=False)
    glucose = models.DecimalField(db_column='Glucose', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    creatinine = models.DecimalField(db_column='Creatinine', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    sodium = models.DecimalField(db_column='Sodium', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    potassium = models.DecimalField(db_column='Potassium', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    chloride = models.DecimalField(db_column='Chloride', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    carbon_dioxide = models.DecimalField(db_column='Carbon_Dioxide', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.

    class Meta:
        db_table = 'BasicMetabolismPanel'
        unique_together = (('pid', 'date'),)


class Commonbloodcount(models.Model):
    id = models.AutoField(primary_key=True)
    pid = models.ForeignKey('Patient', on_delete=models.CASCADE, db_column='PID', blank=True, null=True)  # Field name made lowercase.
    date = models.DateField(auto_now=False, auto_now_add=False)
    wbc = models.DecimalField(db_column='WBC', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    rbc = models.DecimalField(db_column='RBC', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    hemoglobin = models.DecimalField(db_column='Hemoglobin', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    hematocrit = models.DecimalField(db_column='Hematocrit', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    mcv = models.DecimalField(db_column='MCV', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    mch = models.DecimalField(db_column='MCH', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    mchc = models.DecimalField(db_column='MCHC', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    rdw = models.DecimalField(db_column='RDW', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    platelets = models.DecimalField(db_column='Platelets', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    neurophils = models.DecimalField(db_column='Neurophils', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    lymphs = models.DecimalField(db_column='Lymphs', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.
    monocytes = models.DecimalField(db_column='Monocytes', max_digits=19, decimal_places=10, blank=True, null=True)  # Field name made lowercase. This field type is a guess.

    class Meta:
        db_table = 'CommonBloodCount'
        unique_together = (('pid', 'date'),)


class Doctor(models.Model):
    did = models.AutoField(db_column='DID', primary_key=True, blank=True, null=False)  # Field name made lowercase.
    name = models.CharField(max_length=50, blank=True, null=True)
    surname = models.CharField(max_length=50, blank=True, null=True)
    gender = models.CharField(max_length=50, blank=True, null=True)
    dob = models.CharField(max_length=50, db_column='DoB', blank=True, null=True)  # Field name made lowercase.
    country = models.CharField(max_length=50, db_column='Country', blank=True, null=True)  # Field name made lowercase.
    profile_id = models.ForeignKey('Account.UserProfile', on_delete=models.CASCADE, db_column='id',blank=True, null=True)
    class Meta:
        db_table = 'Doctor'


class Mri(models.Model):
    id = models.AutoField(primary_key=True)
    pid = models.ForeignKey('Patient', on_delete=models.CASCADE, db_column='PID', blank=True, null=True)  # Field name made lowercase.
    date = models.DateField(auto_now=False, auto_now_add=False)
    mri = models.ImageField(upload_to='pics/mri')

    class Meta:
        db_table = 'MRI'
        unique_together = (('pid', 'date'),)


class Medication(models.Model):
    medid = models.AutoField(db_column='MEDID', primary_key=True, blank=True, null=False)  # Field name made lowercase.
    name = models.CharField(max_length=50, blank=True, null=True)
    generic_name = models.CharField(max_length=50, blank=True, null=True)

    class Meta:
        db_table = 'Medication'


class Patient(models.Model):
    pid = models.AutoField(db_column='PID', primary_key=True, blank=True, null=False)  # Field name made lowercase.
    name = models.CharField(max_length=50, blank=True, null=True)
    surname = models.CharField(max_length=50, blank=True, null=True)
    gender = models.CharField(max_length=50, blank=True, null=True)
    date = models.DateField(auto_now=False, auto_now_add=False)
    country = models.CharField(max_length=50, db_column='Country', blank=True, null=True)  # Field name made lowercase.
    street_address = models.CharField(max_length=50, db_column='Street_Address', blank=True, null=True)  # Field name made lowercase.
    city = models.CharField(max_length=50, db_column='City', blank=True, null=True)  # Field name made lowercase.
    state = models.CharField(max_length=50, db_column='State', blank=True, null=True)  # Field name made lowercase.
    postal = models.CharField(max_length=50, db_column='Postal', blank=True, null=True)  # Field name made lowercase.
    profile_id = models.ForeignKey('Account.UserProfile', on_delete=models.CASCADE, db_column='id',blank=True, null=True)
    class Meta:
        db_table = 'Patient'


class Prescriptmed(models.Model):
    id = models.AutoField(primary_key=True)
    prescript_id = models.ForeignKey('Prescription', on_delete=models.CASCADE, db_column='Prescript_ID', blank=True, null=True)  # Field name made lowercase.
    medid = models.ForeignKey('Medication', on_delete=models.CASCADE, db_column='MEDID', blank=True, null=True)  # Field name made lowercase.
    description = models.CharField(max_length=50, db_column='Description', blank=True, null=True)  # Field name made lowercase.
    days = models.IntegerField(db_column='Days', blank=True, null=True)  # Field name made lowercase.

    class Meta:
        db_table = 'PrescriptMed'
        unique_together = (('medid', 'prescript_id'),)


class Prescription(models.Model):
    prescript_id = models.AutoField(db_column='Prescript_ID', primary_key=True, blank=True, null=False)  # Field name made lowercase.
    pid = models.ForeignKey(Patient, on_delete=models.CASCADE, db_column='PID', blank=True, null=True)  # Field name made lowercase.
    did = models.ForeignKey(Doctor, on_delete=models.CASCADE, db_column='DID', blank=True, null=True)  # Field name made lowercase.
    date = models.DateField(auto_now=False, auto_now_add=False)

    class Meta:
        db_table = 'Prescription'


class Xray(models.Model):
    id = models.AutoField(primary_key=True)
    pid = models.ForeignKey(Patient, on_delete=models.CASCADE, db_column='PID', blank=True, null=True)  # Field name made lowercase.
    date = models.DateField(auto_now=False, auto_now_add=False)
    xray = models.ImageField(upload_to='pics/xray')

    class Meta:
        db_table = 'Xray'
        unique_together = (('pid', 'date'),)

class patientGrantTable(models.Model):
    id = models.AutoField(primary_key=True)
    pid = models.ForeignKey(Patient, on_delete=models.CASCADE, db_column='PID', blank=True, null=True)
    docid = models.ForeignKey(Doctor, on_delete=models.CASCADE, db_column='DID', blank=True, null=True)

    class Meta:
        db_table = 'patientGrantTable'
