.. _multi_dose_types:

Multiple Dose Types
---------------------

If you have multiple types of dose in your analysis, |eg| two different drugs being prescribed, then you need to give each dose type a name, as shown in :numref:`table_popy_multi_doses`.

.. _table_popy_multi_doses:

.. list-table:: |popy| multi dose type example 
    :header-rows: 1

    * - |type|
      - |time|
      - AMT_DRUG1
      - AMT_DRUG2
      - comment
      
    * - dose:drug1
      - 1.0
      - 100
      - 0
      - 100 units of drug1
      
    * - dose:drug2
      - 2.0
      - 0
      - 200
      - 200 units of drug2
      
    * - dose:drug1
      - 3.0
      - 50
      - 0
      - 50 units of drug1

The data file above creates 2 doses of drug1 and 1 dose of drug2. The script file loading this data set should have a |derivatives| section something like:-

.. code-block:: pyml

    DERIVATIVES: |
        dose[drug1] = @bolus{amt: c[AMT_DRUG1]}
        dose[drug2] = @bolus{amt: c[AMT_DRUG2]}
        d[DEPOT1] = dose[drug1] - m[KE1] * s[DEPOT1]
        d[DEPOT2] = dose[drug2] - m[KE2] * s[DEPOT2]

The important aspect here is that the :ref:`@bolus` doses are defined with names 'drug1' and 'drug2'. These names also appear in the |type| field in the data set as 'dose:drug1' and 'dose:drug2'.

An alternative naming syntax is as follows:-

.. code-block:: pyml

    DERIVATIVES: |
        d[DEPOT1] = @bolus{amt: c[AMT_DRUG1], name: 'drug1'} - m[KE1] * s[DEPOT1]
        d[DEPOT2] = @bolus{amt: c[AMT_DRUG2], name: 'drug2'} - m[KE2] * s[DEPOT2]

Note that when creating a |popy| data set, you only need to specify a name for each type of dose. You can leave the modelling decision of where each dose appears in the compartment model to a later time.
        
