childcount.helpers

PLEASE DO NOT PUT INDICATOR LOGIC HERE!!! The helpers module is only for reusable logic that:

  1. Cannot be elegantly expressed in terms of a childcount.indicator.Indicator.
  2. Are used in many different reports or forms.

Any function that operate on lists of childcount.models.Patient objects, or that involves DB heavy lifting should probably be written as a childcount.indicator.Indicator. That way you get the benefits of caching and the standardized childcount.indicator.Indicator interface.

childcount.helpers.chw

Helper functions that operate on or relate to childcount.models.CHW objects.

childcount.helpers.chw.kids_needing_immunizations(period, chw)[source]

Get a list of children under five years old assigned to this CHW who are:

  1. More than 12 months old who have no known immunization record or who were last known to be not fully immunized, or
  2. Less than 12 months old who have not had an immunization report in the past 90 days.
Parameters:
  • period (An object with start() and end() methods that each return a datetime.datetime) – Time period
  • chw (childcount.models.CHW) – CHW
Returns:

django.db.models.query.QuerySet of childcount.models.Patient

childcount.helpers.chw.kids_needing_muac(period, chw)[source]

Get a list of MUAC-eligible patients assigned to this CHW who have not had a recorded MUAC in the past 90 days (for known healthy children) or the past 30 days (for known malnourished children and children with unknown nutrition status).

Parameters:
  • period (An object with start() and end() methods that each return a datetime.datetime) – Time period
  • chw (childcount.models.CHW) – CHW
Returns:

list of (childcount.models.Patient, childcount.models.reports.NutritionReport) tuples

childcount.helpers.chw.people_without_follow_up(period, chw)[source]

Get a list of people assigned to this CHW who were referred urgently to a clinic who got a late follow-up visit (3-7 days after referral) or no follow-up visit (more than 7 days after referral or never)

Parameters:
  • period (An object with start() and end() methods that each return a datetime.datetime) – Time period
  • chw (childcount.models.CHW) – CHW
Returns:

list of childcount.models.reports.ReferralReport

childcount.helpers.chw.pregnant_needing_anc(period, chw)[source]

Get a list of women assigned to this CHW who are in their 2nd or 3rd trimester of pregnancy who haven’t had ANC visits in last 5 five weeks

Parameters:
  • period (An object with start() and end() methods that each return a datetime.datetime) – Time period
  • chw (childcount.models.CHW) – CHW
Returns:

list of (childcount.models.Patient, last_anc_date, approx_due_date) tuples

childcount.helpers.chw.report_indicators()[source]

childcount.helpers.patient

childcount.helpers.patient.latest_hhv_counseling(period, p)[source]

Format a string containing a human-readable list of counseling codes for this Patient’s last household visit.

Parameters:
  • period (An object with start() and end() methods that each return a datetime.datetime) – Time period
  • p (childcount.models.Patient) – Patient
Returns:

unicode

childcount.helpers.patient.latest_hhv_date(period, p)[source]

Format a string containing a human-readable date for this Patient’s last household visit.

Parameters:
  • period (An object with start() and end() methods that each return a datetime.datetime) – Time period
  • p (childcount.models.Patient) – Patient
Returns:

unicode

childcount.helpers.patient.latest_hhv_raw(period, p)[source]

Look up the latest HouseholdVisitReport for this patient’s household

Parameters:
  • period (An object with start() and end() methods that each return a datetime.datetime) – Time period
  • p (childcount.models.Patient) – Patient
Returns:

childcount.models.reports.HouseholdVisitReport or None

childcount.helpers.patient.latest_imm_report(period, kid)[source]

Look up this patient’s latest immunization report.

Parameters:
  • period (An object with start() and end() methods that each return a datetime.datetime) – Time period
  • p (childcount.models.Patient) – Patient
Returns:

childcount.models.reports.UnderOneReport or None

childcount.helpers.patient.latest_muac(period, p)[source]

Format a string containing this Patient’s last MUAC measurment.

Parameters:
  • period (An object with start() and end() methods that each return a datetime.datetime) – Time period
  • p (childcount.models.Patient) – Patient
Returns:

unicode

childcount.helpers.patient.latest_muac_date(period, p)[source]

Format a string containing a human-readable date and MUAC value for this Patient’s last MUAC .

Parameters:
  • period (An object with start() and end() methods that each return a datetime.datetime) – Time period
  • p (childcount.models.Patient) – Patient
Returns:

unicode

childcount.helpers.patient.latest_muac_raw(period, p)[source]

Look up the latest NutritionReport for this patient with a non-zero MUAC value.

Parameters:
  • period (An object with start() and end() methods that each return a datetime.datetime) – Time period
  • p (childcount.models.Patient) – Patient
Returns:

childcount.models.reports.NutritionReport or None

childcount.helpers.site

childcount.helpers.site.key_indicators()[source]
childcount.helpers.site.summary_stats(period)[source]

Calculates a few key indicators for display on the dashboard.

Parameters:period (An object with start() and end() methods that each return a datetime.datetime) – Time period
Returns:dict

Table Of Contents

Previous topic

childcount.forms

Next topic

childcount.indicators

This Page