The Episode service
The Episode
service in opal.services
provides us with core functionality related
to interacting with episodes in the client.
Constructor
The Episode service is instantiated with the Episode data that comes back from the Episode JSON API.
var episode = new Episode(json_data);
Methods
Episode.getTags
Return a list of the current tags this episode has as strings.
episode.getTags();
// ['mine', 'infectioncontrol']
Episode.getFullName
Return a human readable version of the Patient name suitable for rendering.
episode.getFullName()
// -> 'Jane Doe'
Episode.hasTag
Predicate function that determines whether the episode is tagged with a given tag.
Arguments:
tag
: The tag you are interested in.
Episode.newItem
Instantiate a new subrecord for this episode of a given type.
Arguments:
recordName
: The name of the type of record you want to instantiate.
Example usage:
episode.newItem('diagnosis');
// item (an Item() instance.
Episode.recordEditor.newItem(name)
Takes a string, opens a modal from which the user can create a new subrecord of type name
.
It takes the optional argument of url
which is the url of the template to be opened. This defaults
to the modal form template for the subrecord of name
.
episode.recordEditor.newItem('diagnosis'):
// -> Opens a modal with the diagnosis form and will create a new diagnosis on save
Episode.recordEditor.editItem(name, item)
Open a modal from which the user may edit the item of type name
.
It takes the optional argument of url
which is the url of the template to be opened. This defaults
to the modal form template for the subrecord of name
.
episode.recordEditor.editItem('diagnosis', 0);
// -> Opens a modal that allows the user to edit the first diagnosis