from django.db import models
from datetime import datetime
from django.utils import timezone 
from baseapp.models import patient,employee,disease
# Create your models here.
#Diagnosis
class diagnose(models.Model):
    class Meta:
        verbose_name_plural ="Diagnosis"


    list_order = (('Primary','Primary'),('Secondary','Secondary'))
    list_certainty = (('Confirmed','Confirmed'),('Presumed','Presumed'))
    list_status = (('Ruled In','Ruled In'),('Ruled Out','Ruled Out'))

    diag = models.CharField(max_length=50,blank=True,null=True,verbose_name='Diagnosis',help_text="Enter the diagnosis")
    diag_accept = models.BooleanField(blank=True,null=True,verbose_name="Accept") 
    order = models.CharField(max_length=50,blank=True,null=True,verbose_name='Order',help_text="Select a order",choices=list_order)
    certainty = models.CharField(max_length=50,blank=True,null=True,verbose_name='Certainty',help_text="Select a certainty",choices=list_certainty)
    
    status = models.CharField(max_length=50,blank=True,null=True,verbose_name="Status",help_text="Select a status", choices=list_status)
    diag_notes = models.TextField(max_length=250,blank=True,null=True,verbose_name='Diagnosis Notes')

    fk_patient = models.ForeignKey(patient, on_delete=models.DO_NOTHING,null=True)
    fk_employee = models.ForeignKey(employee, on_delete=models.DO_NOTHING,null=True)
    date_modified = models.DateTimeField(default=timezone.now)
    date_created = models.DateTimeField(auto_now_add=True, null=True)
    

    def __str__(self):
        return str(self.diag) + ' - ' + str(self.order)
    
class condition(models.Model):
    class Meta:
        verbose_name_plural ="Conditions"

    list_stsy = (('Active','Active'),('Inactive','Inactive'),('History of','History of'))

    condi = models.CharField(max_length=50,null=True,verbose_name='Condition',help_text="Enter the condition")
    status = models.CharField(max_length=20,null=True,verbose_name='Status',help_text="Select the current status",choices=list_stsy)
    date_identified = models.DateField(help_text='Date of condition identified', default=datetime.today,verbose_name='Identified Date') 
    action = models.BooleanField(null=True,verbose_name="Action")
    condi_notes = models.TextField(max_length=250,blank=True,null=True,verbose_name='Condition Notes')
    fk_patient = models.ForeignKey(patient, on_delete=models.DO_NOTHING, null=True)
    fk_employee = models.ForeignKey(employee, on_delete=models.DO_NOTHING, null=True)
    date_modified = models.DateTimeField(default=timezone.now)
    date_created = models.DateTimeField(auto_now_add=True, null=True)

    def __str__(self):
        return self.condi + ' - ' + self.status
    

class disease_details(models.Model):
     class Meta:
        verbose_name_plural ="Disease details"

     lst_sts = (('Uncertainty','Uncertainty'),('Need to verify','Need to verify'),('Confirmed','Confirmed'))
     fk_disease = models.ForeignKey(disease,on_delete=models.CASCADE,null=True,verbose_name='Disease',help_text = "Select a disease")
     disease_notes = models.TextField(max_length=250,blank=True,null=True,verbose_name='Disease Notes')
     status = models.CharField(max_length=50,help_text="Status of disease",null=True,verbose_name='Status',choices=lst_sts)
     fk_patient = models.ForeignKey(patient, on_delete=models.DO_NOTHING, null=True,verbose_name='Patient')
     fk_employee  = models.ForeignKey(employee, on_delete=models.DO_NOTHING, null=True,verbose_name='Employee')
     date_modified = models.DateTimeField(default=timezone.now)
     date_created = models.DateTimeField(auto_now_add=True, null=True)
     
     def __str__(self):
          return str(self.fk_disease) + ' - ' + str(self.fk_employee)