-
Notifications
You must be signed in to change notification settings - Fork 7
Using Consumables
- Consumables are used in the provision of a service in the healthcare system (e.g. (e.g. medicines and other necessary materials)
- Consumables are referred to by an
item_code
. - A 'request' for consumables is made during a during an
HSI
event and can be for one or many items at once.
There are a number of steps to using Consumables;
There are two helper function that can assist in finding them item_code
you need.
This will return the int
that is the item_code
for that item.
e.g.
item_code = sim.modules['HealthSystem'].get_item_code_from_item_name("Tenofovir (TDF)/Emtricitabine (FTC), tablet, 300/200 mg")
This will return a dict
of the form {<item_code>: <quantity>}
that corresponds to that package.
e.g.
item_code = sim.modules['HealthSystem'].get_item_codes_from_package_name("HIV Testing Services")
It is common to store all the item_code
s in a convenient structure and to create a method on the disease module
called find_cons_item_codes
or similar, which contains the routines needed to find the item_code
for each consumable that is needed. This can be called at initialise_simulation()
. A common format would be:
def `get_item_code`(self) --> dict:
get_item_code = self.sim.modules['HealthSystem'].get_item_codes_from_package_name
rtn = dict()
rtn['treatment_A'] = get_item_code("item_name_for_treatment_A")
rtn['treatment_B'] = [get_item_code("item_name_for_treatment_B")] + [get_item_code("item_name_something_else")]
rtn['treatment_C'] = get_item_code("item_name_for_treatment_C")
Do:
-
- Group all the requests in one place: e.g. factorize the looking-up of the
item_code
s into a method and call it atinitialise_simulation
.
- Group all the requests in one place: e.g. factorize the looking-up of the
- Use the helper functions in
HealthSystem
:get_item_code_from_item_name
andget_item_codes_from_package_name
Do not:
- Look-up the item_code at run-time in the HSI (this will cause the look-up to happen every time the HSI is created, which could be a lot!)
- Scatter looking up of consumables throughout the code.
- Look-up the codes manually using the internal data of the
HealthSystem
module.
All request for consumables are done using get_consumables
, which is a method on the HSI_Event
base-class. So, within an HSI
it's accessed with self.get_consumable()
. It's signature is:
def get_consumables(self,
item_codes: Union[np.integer, int, list, set, dict],
to_log=True,
return_individual_results=False
) -> Union[bool, dict]:
Note that:
-
The argument
item_code
can be provided as:- an
int
, representing the singleitem_code
requested (and for which a quantity of 1 is assumed); - a
list
orset
, representing the collection ofitem_code
s that are needed (for each of a which a quantity of 1 is assumed); - a
dict
of the form{<item_code>: <quantity>}
, in which the quantity of eachitem_code
is specified;
- an
-
The argument
to_log
, determines if the request (whatever its outcome) is logged (to['tlo.methods.healthsystem']['Consumables']
). The defaults toTrue
but can over-ridden (e.g. to query availability only). -
The method return either a
bool
[default] (indicating that all the items requested are available) or adict
(indicating the availability of each requesteditem_code
).- The default is always to return a
bool
but this can be over-ridden with the argumentreturn_individual_results=True
- The default is always to return a
Examples:
if self.get_consumables(self.module.cons_codes['treatment_A']):
# do the treatment
# Construct request for ten of each item_code used in treatment_B
cons = {_i: 10 for _i in self.module.cons_codes['treatment_B']}
# Check availability (getting individual results)
avail = self.get_consumables(cons, return_individual_results=True)
# Check if most of the items are available
most_avail = sum(a.values())/len(a) > 0.5
Notes:
- Use the same formats for
item_code
, when specifying the consumable requirement of aDxTest
.
The following options (parsed to the HealthSystem
) are relevant:
-
cons_availability
: This can benone
(no consumable is available)all
(all consumables are available) ordefault
[default] (consumables are available according to a probability specified in a the relevantResourceFile
). -
disable
: In this mode, all consumables are considered to be available but there is no logging.
TLO Model Wiki