=================
Drug applications
=================

The purpose of the :mod:`drug_applications` component is to track the
application of chemical substances, e.g. anaesthetics, to a preparation,
whether through perfusion, injection or otherwise.

This component depends on the :mod:`chemistry` component, the :mod:`units`
component and the :mod:`experiments` component.

Recording an injection
----------------------

We will assume that we have already created an :class:`Experiment` object (see
the documentation for the :doc:`experiments` component for details) and a :class:`Solution`
object representing the substance to be injected::

  >>> from helmholtz.drug_applications.models import Injection, Perfusion
  >>> from helmholtz.units.fields import PhysicalQuantity as Q
  >>> from datetime import datetime
  >>> expt
  <Experiment: my_latest_experiment>
  >>> solution.list_components()
  [u'134.00 mM NaCl', u'5.00 mM KCl', u'10.00 mM glucose']
  >>> inj = Injection(experiment=expt, solution=solution, volume=Q(20, "ml"),
  ...                 time=datetime.now())
  >>> inj.save()
  
Recording a perfusion
---------------------

Recording a perfusion is similar to recording an injection, but we store the
flow rate instead of the volume, and we need both a start and an end time::

  >>> perf = Perfusion(experiment=expt, solution=solution, rate=Q(100.0, "ml/h"),
  ...                  start=datetime.now())
  >>> perf.save()
  
Some time later, we stop the perfusion::

  >>> perf.end = datetime.now()
  >>> perf.save()


Reference
---------

.. automodule:: helmholtz.drug_applications.models

.. autoclass:: Perfusion
   :members:
   
.. autoclass:: Injection
   :members: