<commit_before>'''The datamodels for all various types required for followup tracking in  the
SNHC clintools patient tracking system'''
from django.db import models
from pttrack import models as mymodels
import django.utils.timezone

# pylint: disable=I0011,E1305


class NoShowReason(models.Model):
    '''Simple text-contiaining class for storing the different reasons a
    patient might not have gone to a scheduled appointment.'''

    name = models.CharField(max_length=100, primary_key=True)

    def __unicode__(self):
        return self.name


class NoAptReason(models.Model):
    '''Simple text-contiaining class for storing the different kinds of
    clinics a patient can be referred to (e.g. PCP, ortho, etc.)'''

    name = models.CharField(max_length=100, primary_key=True)

    def __unicode__(self):
        return self.name


class ContactResult(models.Model):
    '''Abstract base model for representing the resolution to a followup
    attempt with a patient (e.g. no answer w/ voicemail).'''

    name = models.CharField(max_length=100, primary_key=True)

    def __unicode__(self):
        return self.name


class Followup(mymodels.Note):
    '''The base followup class used in all different types of patient followup
    notes. Can also be instantiated as a 'general follouwp' type.'''

    class Meta:
        abstract = True

    contact_method = models.ForeignKey(mymodels.ContactMethod)
    contact_resolution = models.ForeignKey(ContactResult)

    comments = models.TextField(blank=True, null=True)

    def type(self):
        '''Returns a short string value used as a key to determine which type
        of followup note this is. Human readable.'''

        # in a brutally ugly turn of events, there doesn't appear to be a good
        # way to overridde this method in subclasses. Behold the hacky result:
        for child in ["labfollowup", "generalfollowup", "vaccinefollowup"]:
            # you may ask "where did those strings come from?" or "how do you
            # know that it's all lower case?"... MYSTERIES FOR THE AGES.
            if hasattr(self, child):
                return getattr(self, child).type()

        return "General"

    def short_text(self):
        '''Return a short text description of this followup and what happened.
        Used on the patient chart view as the text in the list of followups.'''

        return self.comments

    def attribution(self):
        '''Returns a string that is used as the attribution (i.e. "John at
        4pm") for this note.'''
        return " ".join([self.author.name(), "on", str(self.written_date())])

    def written_date(self):
        '''Returns a python date object for when this followup was written.'''
        return self.written_datetime.date()

    def __unicode__(self):
        return " ".join(["Followup for ", self.patient.name(), " on ",
                         str(self.written_date())])


class GeneralFollowup(Followup):
    '''Datamodel for a general followup. Exists only so that base followup can
    be abstract.'''
    pass


class VaccineFollowup(Followup):
    '''Datamodel for a followup of a vaccine administration'''

    SUBSQ_DOSE_HELP = "Are they coming back for another dose?"
    subsq_dose = models.BooleanField(help_text=SUBSQ_DOSE_HELP)

    DOSE_DATE_HELP = "When is the next dose?"
    dose_date = models.DateField(blank=True,
                                 null=True,
                                 help_text=DOSE_DATE_HELP)

    def type(self):<commit_msg>Update name of subsequent dose in vaccine followup.<commit_after>'''The datamodels for all various types required for followup tracking in  the
SNHC clintools patient tracking system'''
from django.db import models
from pttrack import models as mymodels
import django.utils.timezone

# pylint: disable=I0011,E1305


class NoShowReason(models.Model):
    '''Simple text-contiaining class for storing the different reasons a
    patient might not have gone to a scheduled appointment.'''

    name = models.CharField(max_length=100, primary_key=True)

    def __unicode__(self):
        return self.name


class NoAptReason(models.Model):
    '''Simple text-contiaining class for storing the different kinds of
    clinics a patient can be referred to (e.g. PCP, ortho, etc.)'''

    name = models.CharField(max_length=100, primary_key=True)

    def __unicode__(self):
        return self.name


class ContactResult(models.Model):
    '''Abstract base model for representing the resolution to a followup
    attempt with a patient (e.g. no answer w/ voicemail).'''

    name = models.CharField(max_length=100, primary_key=True)

    def __unicode__(self):
        return self.name


class Followup(mymodels.Note):
    '''The base followup class used in all different types of patient followup
    notes. Can also be instantiated as a 'general follouwp' type.'''

    class Meta:
        abstract = True

    contact_method = models.ForeignKey(mymodels.ContactMethod)
    contact_resolution = models.ForeignKey(ContactResult)

    comments = models.TextField(blank=True, null=True)

    def type(self):
        '''Returns a short string value used as a key to determine which type
        of followup note this is. Human readable.'''

        # in a brutally ugly turn of events, there doesn't appear to be a good
        # way to overridde this method in subclasses. Behold the hacky result:
        for child in ["labfollowup", "generalfollowup", "vaccinefollowup"]:
            # you may ask "where did those strings come from?" or "how do you
            # know that it's all lower case?"... MYSTERIES FOR THE AGES.
            if hasattr(self, child):
                return getattr(self, child).type()

        return "General"

    def short_text(self):
        '''Return a short text description of this followup and what happened.
        Used on the patient chart view as the text in the list of followups.'''

        return self.comments

    def attribution(self):
        '''Returns a string that is used as the attribution (i.e. "John at
        4pm") for this note.'''
        return " ".join([self.author.name(), "on", str(self.written_date())])

    def written_date(self):
        '''Returns a python date object for when this followup was written.'''
        return self.written_datetime.date()

    def __unicode__(self):
        return " ".join(["Followup for ", self.patient.name(), " on ",
                         str(self.written_date())])


class GeneralFollowup(Followup):
    '''Datamodel for a general followup. Exists only so that base followup can
    be abstract.'''
    pass


class VaccineFollowup(Followup):
    '''Datamodel for a followup of a vaccine administration'''

    SUBSQ_DOSE_HELP = "Has the patient committed to coming back for another dose?"
    subsq_dose = models.BooleanField(verbose_name=SUBSQ_DOSE_HELP)

    DOSE_DATE_HELP = "When does the patient want to get their next dose (if applicable)?"
    dose_date = models.DateField(blank=True,
                                 null=True,
                                 help_text=DOSE_DATE_HELP)

    def type(self):
{'fraction_non_alphanumeric': 0.08828070175438596, 'fraction_numerical': 0.0050526315789473685, 'mean_word_length': 2.952301719356628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5365205', 'n_tokens_mistral': 2047, 'n_tokens_neox': 1932, 'n_words': 730}