<commit_before>## opal.models.Episode

The `opal.models.Episode` class represents an episode of care for a patient. This can be either 
an inpatient stay, an outpatient treatment, a telephone liaison, an appointment at a clinic, 
or any other arbitrarially defined period of care.

### Fields

#### Episode.category

The category of this episode - e.g. inpatient, outpatient et cetera.
This defaults to whatever is set on your application's subclass of 
`opal.core.application.OpalApplication` - which itseflf defaults to 'inpatient'.

#### Episode.patient

A foreign key relationship to the patient for whom this episode concerns.

#### Episode.active

A boolean to provide a quick lookup for whether this is an active or closed episode.

#### Episode.date_of_admission

If this is an inpatient episode, the date of admission.

#### Episode.discharge_date

If this is an inpatient episode, the date of discharge.

#### Episode.date_of_episode

If this is an episode that occurs on one date (like a clinic visit or telephone liaison), the 
date of that event.

#### Episode.consistency_token 

A (automatically generated) hash of the above fields. This is used for detecting concurrent edits.

### Methods

The Episode model has the following methods: 

#### Episode.to_dict

Return a dictionary of field value pairs for this episode

    episode.to_dict(user)

Arguments: 

* `user` The User for whom we want to serialise this episode

Keywords: 

* `shallow` Boolean to indicate whether we want just this episode, or also a sorted set of 
previous and subsequent episodes

#### Episode.get_tag_names


Arguments:

* `user` The user for whom we want the tag names.

Return the current active tag names for this Episode as strings.

    episode.get_tag_names(user)
    # ['mine', 'infectioncontrol']


#### Episode.set_tag_names


Arguments:

* `tag_names` The list of tags that we want to be active for this Episode.
* `user` The user for whom we want the tag names.

Return the current active tag names for this Episode as strings.

    episode.set_tag_names(['mine', 'infectioncontrol'], user)
    


### Manager

The custom manager for Episodes has the following methods:

#### Episode.objects.ever_tagged(team)

Return a list of episodes ever tagged to `team`

Arguments:

* `team` The `Team.name` of the team you are interested in.

#### Episode.objects.serialised()

Return a set of serialised episodes.

    Episode.objects.serialised(User, [episode, ...], historic_tags=False)

Arguments:

* `user` The User for whom we want to serialise this episode
* `episodes` An iterable of Episode instances

Keywords: 

* `historic_tags` A boolean to indicate whether the user desires historic or just current tags to 
be serialised<commit_msg>remove method that's been deleted from the docs<commit_after>## opal.models.Episode

The `opal.models.Episode` class represents an episode of care for a patient. This can be either
an inpatient stay, an outpatient treatment, a telephone liaison, an appointment at a clinic,
or any other arbitrarially defined period of care.

### Fields

#### Episode.category

The category of this episode - e.g. inpatient, outpatient et cetera.
This defaults to whatever is set on your application's subclass of
`opal.core.application.OpalApplication` - which itseflf defaults to 'inpatient'.

#### Episode.patient

A foreign key relationship to the patient for whom this episode concerns.

#### Episode.active

A boolean to provide a quick lookup for whether this is an active or closed episode.

#### Episode.date_of_admission

If this is an inpatient episode, the date of admission.

#### Episode.discharge_date

If this is an inpatient episode, the date of discharge.

#### Episode.date_of_episode

If this is an episode that occurs on one date (like a clinic visit or telephone liaison), the
date of that event.

#### Episode.consistency_token

A (automatically generated) hash of the above fields. This is used for detecting concurrent edits.

### Methods

The Episode model has the following methods:

#### Episode.to_dict

Return a dictionary of field value pairs for this episode

    episode.to_dict(user)

Arguments:

* `user` The User for whom we want to serialise this episode

Keywords:

* `shallow` Boolean to indicate whether we want just this episode, or also a sorted set of
previous and subsequent episodes

#### Episode.get_tag_names


Arguments:

* `user` The user for whom we want the tag names.

Return the current active tag names for this Episode as strings.

    episode.get_tag_names(user)
    # ['mine', 'infectioncontrol']


#### Episode.set_tag_names


Arguments:

* `tag_names` The list of tags that we want to be active for this Episode.
* `user` The user for whom we want the tag names.

Return the current active tag names for this Episode as strings.

    episode.set_tag_names(['mine', 'infectioncontrol'], user)



### Manager

The custom manager for Episodes has the following methods:

#### Episode.objects.serialised()

Return a set of serialised episodes.

    Episode.objects.serialised(User, [episode, ...], historic_tags=False)

Arguments:

* `user` The User for whom we want to serialise this episode
* `episodes` An iterable of Episode instances

Keywords:

* `historic_tags` A boolean to indicate whether the user desires historic or just current tags to
be serialised
{'fraction_non_alphanumeric': 0.0746771476698484, 'fraction_numerical': 0.0, 'mean_word_length': 4.312127236580517, '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': 41, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5298245', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1432, 'n_words': 695}