本文整理汇总了Python中snisi_core.models.Periods.MonthPeriod.all_from方法的典型用法代码示例。如果您正苦于以下问题:Python MonthPeriod.all_from方法的具体用法?Python MonthPeriod.all_from怎么用?Python MonthPeriod.all_from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snisi_core.models.Periods.MonthPeriod
的用法示例。
在下文中一共展示了MonthPeriod.all_from方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dashboard
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
def dashboard(request, **kwargs):
now = timezone.now()
last_period = MonthPeriod.current().previous() if now.day < 26 else None
periods = MonthPeriod.all_from(
MonthPeriod.from_url_str("11-2014"), last_period)
entity = request.user.location.casted()
context = {
'periods': periods,
'entity': entity,
}
if entity.has_ureni or entity.has_urenas:
context.update({
'sam_performance': SAMPerformanceTable(entity=entity,
periods=periods)
})
if entity.has_urenam:
context.update({
'mam_performance': MAMPerformanceTable(entity=entity,
periods=periods)
})
return render(request, kwargs.get('template_name',
'nutrition/dashboard.html'), context)
示例2: handle
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
def handle(self, *args, **options):
logger.info("Issue #67. Removing expecteds for djenne entities.")
january = MonthPeriod.from_url_str("12-2014")
periods = MonthPeriod.all_from(january)
entity_slugs = ['ANT9', 'M894', 'C332']
for exp in ExpectedReporting.objects.filter(
period__in=periods, entity__slug__in=entity_slugs):
logger.debug(exp)
exp.delete()
logger.info("Disable health area if not already")
for slug in entity_slugs:
area_slug = "Z{}".format(slug)
e = Entity.objects.get(slug=area_slug)
if e and e.active:
logger.info(e)
e.active = False
e.save()
logger.info("Remove from clusters")
Participation.objects.filter(entity__slug__in=entity_slugs).delete()
logger.info("Update cluster cache")
call_command("update-cluster-caches")
logger.info("done.")
示例3: custom_indicator
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
def custom_indicator(request, **kwargs):
context = {}
cluster = Cluster.get_or_none('malaria_monthly_routine')
speriod = ExpectedReporting.objects \
.order_by('period__start_on').first().period
all_periods = MonthPeriod.all_from(speriod)
context.update({
'all_periods': [(p.strid(), p) for p in reversed(all_periods)],
'raw_indicators': MalariaR.data_fields,
'entities': cluster.members(),
})
return render(request,
kwargs.get('template_name', 'malaria/custom_indicator.html'),
context)
示例4: gen_all_weekagg
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
def gen_all_weekagg(self):
logger.info("Generate AggWeeklyMalariaR")
for month_period in MonthPeriod.all_from(
DailyMalariaR.objects.all().first().period,
DailyMalariaR.objects.all().last().period):
# loop on fixed weeks and try to find a period and report
for periodcls in period_classes:
period = periodcls.find_create_from(
month_period.middle().year, month_period.middle().month)
if period is None:
continue
# skip if period is complete
if AggWeeklyMalariaR.objects.filter(
period=period).count() == nbal:
continue
gen_time = period.end_on + \
datetime.timedelta(seconds=28800) # 8h
DEBUG_change_system_date(gen_time, True)
for entity in week_agg_locations:
# skip if report exists
if AggWeeklyMalariaR.objects.filter(period=period,
entity=entity).count():
continue
agg_report = AggWeeklyMalariaR.create_from(
period=period,
entity=entity,
created_by=autobot)
logger.info("Created {}".format(agg_report))
示例5: handle
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
def handle(self, *args, **options):
autobot = Provider.get_or_none('autobot')
reportcls_slug = "malaria_monthly_routine_aggregated"
rclass = ReportClass.get_or_none(reportcls_slug)
charge_sis = Role.get_or_none("charge_sis")
first_period = MonthPeriod.from_url_str(
options.get('start_period') if options.get('start_period')
else "09-2011")
last_period = MonthPeriod.from_url_str(
options.get('end_period') if options.get('end_period')
else "03-2014")
first_period_mopti_district = MonthPeriod.from_url_str("09-2013")
first_period_mopti_region = MonthPeriod.from_url_str("01-2014")
mali = Entity.get_or_none("mali")
def entity_expected_for(entity, period, region_level=False):
if period > last_period:
return False
if entity is mali:
return period >= first_period
region = entity.get_health_region()
if region.slug in ('9GR8', '2732'):
return period >= first_period
elif region.slug == 'SSH3':
if region_level:
return period >= first_period_mopti_district
if entity.slug == 'HFD9':
return period >= first_period_mopti_district
else:
return period >= first_period_mopti_region
else:
return False
# remove old ones if requested
if options.get('clear'):
ExpectedReporting.objects.filter(
report_class__slug=reportcls_slug).delete()
receipts = [r.receipt for r in AggMalariaR.objects.all()]
AggMalariaR.objects.filter(receipt__in=receipts)
SNISIReport.objects.filter(receipt__in=receipts).delete()
ExpectedValidation.objects.filter(
report__receipt__in=receipts).delete()
cluster = Cluster.get_or_none("malaria_monthly_routine")
periods = MonthPeriod.all_from(first_period, last_period)
districts = [e for e in cluster.members()
if e.type.slug == 'health_district']
regions = [e for e in cluster.members()
if e.type.slug == 'health_region']
# loop on periods
for period in periods:
reporting_period = period.following()
logger.info("Switching to {}".format(period))
region_validation_period = DefaultRegionValidationPeriod \
.find_create_by_date(reporting_period.middle())
# change date to beginning
DEBUG_change_system_date(reporting_period.start_on, True)
# loop on all districts/region/country
for entity in districts + regions + [mali]:
if not entity_expected_for(
entity, period, entity.type.slug == 'health_region'):
continue
logger.info("\tCreating for {}".format(entity))
# create expected reporting
ExpectedReporting.objects.create(
report_class=rclass,
reporting_role=charge_sis if entity is not mali else None,
period=period,
within_period=False,
entity=entity,
within_entity=False,
amount_expected=ExpectedReporting.EXPECTED_SINGLE,
completion_status=ExpectedReporting.COMPLETION_MISSING)
# change date to 16
district_date = datetime.datetime(
reporting_period.start_on.year,
reporting_period.start_on.month,
16, 8, 0).replace(tzinfo=timezone.utc)
DEBUG_change_system_date(district_date, True)
# loop on all districts
for district in districts:
if not entity_expected_for(district, period):
continue
logger.info("\tAt district {}".format(district))
# auto-validate non-validated reports
#.........这里部分代码省略.........
示例6: Command
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
import datetime
import logging
from django.core.management.base import BaseCommand
from django.utils import timezone
from snisi_core.models.Entities import Entity
from snisi_core.models.Periods import MonthPeriod
from snisi_core.models.Projects import Cluster, Participation
from snisi_tools.datetime import DEBUG_change_system_date
logger = logging.getLogger(__name__)
speriod = MonthPeriod.from_url_str("01-2013")
eperiod = MonthPeriod.from_url_str("12-2013")
periods = MonthPeriod.all_from(speriod, eperiod)
class Command(BaseCommand):
def handle(self, *args, **options):
coverage_cluster = Cluster.objects.get(slug="vacc_coverage_routine")
DEBUG_change_system_date(
MonthPeriod.from_url_str("12-2012").end_on
- datetime.timedelta(days=5), True)
mali = Entity.get_or_none("mali")
regions = ['2732']
示例7: cataract_mission_browser
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
def cataract_mission_browser(request,
entity_slug=None,
period_str=None,
**kwargs):
context = {}
root = request.user.location
cluster = Cluster.get_or_none('cataract')
entity = Entity.get_or_none(entity_slug)
if entity is None:
entity = root
if entity is None:
raise Http404("Aucune entité pour le code {}".format(entity_slug))
# make sure requested entity is in cluster
ensure_entity_in_cluster(cluster, entity)
# check permissions on this entity and raise 403
provider_allowed_or_denied(request.user, 'access_cataract', entity)
# mission browser is reserved to district-level and above
ensure_entity_at_least(entity, 'health_district')
def period_from_strid(period_str, reportcls=None):
period = None
if period_str:
try:
period = Period.from_url_str(period_str).casted()
except:
pass
return period
period = period_from_strid(period_str)
if period is None:
period = MonthPeriod.current()
try:
first_period = MonthPeriod.find_create_by_date(
CATMissionR.objects.all()
.order_by('period__start_on')[0].period.middle())
except IndexError:
first_period = MonthPeriod.current()
all_periods = MonthPeriod.all_from(first_period)
context.update({
'all_periods': [(p.strid(), p) for p in reversed(all_periods)],
'period': period,
'base_url': get_base_url_for_period(
view_name='cataract_missions', entity=entity,
period_str=period_str or period.strid())
})
context.update(entity_browser_context(
root=root, selected_entity=entity,
full_lineage=['country', 'health_region', 'health_district'],
cluster=cluster))
# retrieve list of missions for that period
missions = CATMissionR.objects.filter(
period=period,
entity__slug__in=[e.slug for e in entity.get_health_districts()])
context.update({'missions': missions})
return render(request,
kwargs.get('template_name', 'cataract/missions_list.html'),
context)
示例8: cataract_dashboard
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
def cataract_dashboard(request,
entity_slug=None,
perioda_str=None,
periodb_str=None,
**kwargs):
context = {}
root = request.user.location
cluster = Cluster.get_or_none('cataract')
entity = Entity.get_or_none(entity_slug)
if entity is None:
entity = root
if entity is None:
raise Http404("Aucune entité pour le code {}".format(entity_slug))
# make sure requested entity is in cluster
ensure_entity_in_cluster(cluster, entity)
# check permissions on this entity and raise 403
provider_allowed_or_denied(request.user, 'access_cataract', entity)
# mission browser is reserved to district-level and above
ensure_entity_at_least(entity, 'health_district')
def period_from_strid(period_str, reportcls=None):
period = None
if period_str:
try:
period = Period.from_url_str(period_str).casted()
except:
pass
return period
perioda = period_from_strid(perioda_str)
periodb = period_from_strid(periodb_str)
if periodb is None:
periodb = MonthPeriod.current()
if perioda is None:
perioda = periodb
if perioda is None or periodb is None:
raise Http404("Période incorrecte.")
if perioda > periodb:
t = perioda
perioda = periodb
periodb = t
del(t)
try:
first_period = MonthPeriod.find_create_by_date(
CATMissionR.objects.all().order_by(
'period__start_on')[0].period.middle())
except IndexError:
first_period = MonthPeriod.current()
all_periods = MonthPeriod.all_from(first_period)
periods = MonthPeriod.all_from(perioda, periodb)
context.update({
'all_periods': [(p.strid(), p) for p in reversed(all_periods)],
'periods': periods,
'perioda': perioda,
'periodb': periodb,
'base_url': get_base_url_for_periods(
view_name='cataract_dashboard',
entity=entity,
perioda_str=perioda_str or perioda.strid(),
periodb_str=periodb_str or periodb.strid())
})
context.update(entity_browser_context(
root=root, selected_entity=entity,
full_lineage=['country', 'health_region', 'health_district'],
cluster=cluster))
# retrieve Indicator Table
from snisi_cataract.indicators import (MissionDataSummary,
CumulativeSurgeryData)
missions_followup = MissionDataSummary(entity=entity,
periods=periods)
cumulative_surgeries = CumulativeSurgeryData(entity=entity,
periods=periods)
context.update({
'missions_followup': missions_followup,
'cumulative_surgeries': cumulative_surgeries,
})
return render(request,
kwargs.get('template_name', 'cataract/dashboard.html'),
context)
示例9: handle
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
def handle(self, *args, **options):
speriod = MonthPeriod.from_url_str("01-2013")
eperiod = MonthPeriod.from_url_str("12-2013")
periods = MonthPeriod.all_from(speriod, eperiod)
autobot = Provider.get_or_none("autobot")
for period in periods:
for entity_slug in ['ACE3', 'KTE4', '3ZF3']:
entity = Entity.get_or_none(entity_slug)
if entity_slug == 'ACE3' and period.middle().month >= 10:
continue
if entity_slug == 'KTE4' and period.middle().month >= 9:
continue
day_periods = DayPeriod.objects.filter(
start_on__gte=period.start_on,
end_on__lte=period.end_on)
day_reports = EpidemioMalariaR.objects.filter(
period__in=day_periods,
entity=entity)
# change date to begining of period
DEBUG_change_system_date(period.start_on, True)
# create expected if not exist
eo = ExpectedReporting.objects.get(
period=period, entity__slug='S5C4')
expected_reporting = eo.clone(
save=True,
entity=entity,
completion_status=ExpectedReporting.COMPLETION_MISSING)
DEBUG_change_system_date(
period.start_on + timedelta(days=1), True)
provider = Provider.objects.get(
location=entity, role__slug='dtc')
report = MalariaR.start(
period=period,
entity=entity,
created_by=provider,
arrival_status=MalariaR.ON_TIME)
def sum_days(fields):
fields = [fields] \
if not isinstance(fields, (tuple, list)) else fields
return sum([sum([getattr(r, field, 0)
for r in day_reports for field in fields])])
report.fill_blank()
report.add_underfive_data(
total_consultation_all_causes=sum_days(
'u5_total_consultation_all_causes'),
total_suspected_malaria_cases=sum_days(
'u5_total_suspected_malaria_cases'),
total_simple_malaria_cases=sum_days(
'u5_total_simple_malaria_cases'),
total_severe_malaria_cases=sum_days(
'u5_total_severe_malaria_cases'),
total_tested_malaria_cases=sum_days(
['u5_total_rdt_tested_malaria_cases',
'u5_total_ts_tested_malaria_cases']),
total_confirmed_malaria_cases=sum_days(
['u5_total_rdt_confirmed_malaria_cases',
'u5_total_ts_confirmed_malaria_cases']),
total_treated_malaria_cases=0,
total_inpatient_all_causes=0,
total_malaria_inpatient=0,
total_death_all_causes=sum_days(
'u5_total_death_all_causes'),
total_malaria_death=sum_days(
'u5_total_malaria_death'),
total_distributed_bednets=0)
report.add_overfive_data(
total_consultation_all_causes=sum_days(
'o5_total_consultation_all_causes'),
total_suspected_malaria_cases=sum_days(
'o5_total_suspected_malaria_cases'),
total_simple_malaria_cases=sum_days(
'o5_total_simple_malaria_cases'),
total_severe_malaria_cases=sum_days(
'o5_total_severe_malaria_cases'),
total_tested_malaria_cases=sum_days(
['o5_total_rdt_tested_malaria_cases',
'o5_total_ts_tested_malaria_cases']),
total_confirmed_malaria_cases=sum_days(
['o5_total_rdt_confirmed_malaria_cases',
'o5_total_ts_confirmed_malaria_cases']),
total_treated_malaria_cases=0,
total_inpatient_all_causes=0,
total_malaria_inpatient=0,
total_death_all_causes=sum_days(
'o5_total_death_all_causes'),
#.........这里部分代码省略.........
示例10: dashboard
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
def dashboard(request, **kwargs):
now = timezone.now()
last_period = MonthPeriod.current().previous() if now.day < 26 else None
if now.day < 10:
last_period = last_period.previous()
periods = MonthPeriod.all_from(
MonthPeriod.from_url_str("11-2014"), last_period)
entity = request.user.location.casted()
fwp = NutWeekPeriod.find_create_by_date(datetime.datetime(2014, 12, 1))
lwp = NutWeekPeriod.find_create_by_date(datetime.datetime(2015, 6, 26))
wperiods = NutWeekPeriod.all_from(fwp, lwp)
imatrix = OrderedDict([
('promptitude', TableauPromptitudeRapportage),
('promptitude_graph', FigurePromptitudeRapportage),
('w_promptitude', WeekTableauPromptitudeRapportage),
('w_promptitude_graph', WeekFigurePromptitudeRapportage),
])
gp = lambda s: wperiods if s.startswith('w_') else periods
sm_indics = {slug: icls(entity=entity, periods=gp(slug))
for slug, icls in imatrix.items()}
def pc(a, b):
try:
return b / a
except ZeroDivisionError:
return 0
mopti = Entity.get_or_none("SSH3")
nb_hc = len(mopti.get_health_centers())
nb_months = len(periods)
nb_exp = nb_hc * nb_months
nb_received = NutritionR.objects.all().count()
nb_received_it = NutritionR.objects.filter(
arrival_status=NutritionR.ON_TIME).count()
# nb_stock = len([1 for r in NutritionStocksR.objects.all()
# if r.has_stockout()])
nb_stock_thera = len([1 for r in NutritionStocksR.objects.all()
if r.has_therapeutic_stockout()])
nb_stock_drug = len([1 for r in NutritionStocksR.objects.all()
if r.has_drug_stockout()])
nb_weeks = len(wperiods)
nb_expw = nb_hc * nb_weeks
nb_receivedw = WeeklyNutritionR.objects.all().count()
nb_received_itw = WeeklyNutritionR.objects.filter(
arrival_status=WeeklyNutritionR.ON_TIME).count()
ds_received = [(ds.name,
pc(len(ds.get_health_centers()) * nb_months,
NutritionR.objects.filter(
entity__slug__in=[hc.slug
for hc in ds.get_health_centers()])
.count()))
for ds in mopti.get_health_districts()]
ds_auto_val = [(ds.name,
pc(len(ds.get_health_centers()) * nb_months,
NutritionR.objects.filter(
entity__slug__in=[hc.slug
for hc in ds.get_health_centers()],
auto_validated=False)
.count()))
for ds in mopti.get_health_districts()]
nb_hc_100 = len([hc for hc in mopti.get_health_centers()
if NutritionR.objects.filter(entity__slug=hc.slug)
.count() == nb_months])
overall_table = OrderedDict([
("Nombre de centres", nb_hc),
("Nombre de mois", nb_months),
("Nombre de rapports attendus", nb_exp),
("Nombre de rapports reçus", nb_received),
("Taux de complétude moyen", pc(nb_exp, nb_received)),
("Nombre de rapports reçus à temps", nb_received_it),
("Taux de promptitude moyen", pc(nb_exp, nb_received_it)),
("Nombre de semaines", nb_weeks),
("Nombre de rapports hebdo attendus", nb_expw),
("Nombre de rapports hebdo reçus", nb_receivedw),
("Taux de complétude hebdo moyen", pc(nb_expw, nb_receivedw)),
("Nombre de rapports hebdo reçus à temps", nb_received_itw),
("Taux de promptitude hebdo moyen", pc(nb_expw, nb_received_itw)),
("Nombre de rapports avec de mauvais indicateurs de performances", 0),
("Pourcentage de mauvais indicateurs de performances", 0),
("Classement du rapportage (complétude) par DS", "-"),
])
for idx, dsdd in enumerate(sorted(ds_received,
key=lambda x: x[1], reverse=True)):
overall_table.update({
"nº {} – DS de {}".format(idx + 1, dsdd[0]): dsdd[1]})
overall_table.update({"Taux de rapports validés par les districts": "-"})
for idx, dsdd in enumerate(sorted(ds_auto_val,
#.........这里部分代码省略.........
示例11: health_center_report
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
def health_center_report(entity, periods, graph_periods, quarter_num, year):
def get_widgets_for(document, text, widget,
is_table=True, break_before=False):
widgets = [title_for_text(document=document,
text=text,
break_before=break_before)]
if is_table:
widgets.append(neutral_style(document, None))
widgets.append(widget)
return widgets
# special tables
slug = "malaria_monthly_routine"
last_period = periods[-1]
first_period = last_period
for _ in range(0, 11):
first_period = first_period.previous()
count_periods = MonthPeriod.all_from(first_period, last_period)
def _pc(num, denum):
try:
return num / denum * 100
except ZeroDivisionError:
return 0
def add_tableau2(document, section, ref_periods, name, caption):
def count_value_for(field):
def _pc(num, denum):
try:
return num / denum * 100
except ZeroDivisionError:
return 0
count = 0
total = 0
for p in ref_periods:
exp = ExpectedReporting.objects.filter(
entity=entity, period=p, report_class__slug=slug)
if exp.count() == 0:
continue
exp = exp.get()
total += 1
if not exp.satisfied:
continue
if getattr(exp.arrived_report(), field, None) == MalariaR.NO:
count += 1
return count, _pc(count, total)
act_children, pc_act_children = count_value_for(
'stockout_act_children')
act_youth, pc_act_youth = count_value_for('stockout_act_youth')
act_adult, pc_act_adult = count_value_for('stockout_act_adult')
datamatrix = [
["", "Nb. mois", "%"],
["CTA Enfant-nourisson", act_children, pc_act_children],
["CTA Adolescent", act_youth, pc_act_youth],
["CTA Adulte", act_adult, pc_act_adult],
]
table = generic_table(datamatrix)
text = "{} : {}".format(name, caption)
for widget in get_widgets_for(document, text, table, True):
section.append(widget)
def add_tableau3(document, section, ref_periods, name, caption):
arrived = 0
on_time = 0
total = 0
for p in ref_periods:
exp = ExpectedReporting.objects.filter(
entity=entity, period=p, report_class__slug=slug)
if exp.count() == 0:
continue
exp = exp.get()
total += 1
if not exp.satisfied:
continue
arrived += 1
if getattr(exp.arrived_report(),
'arrival_status', None) == MalariaR.ON_TIME:
on_time += 1
pc_on_time = _pc(on_time, total)
pc_arrived = _pc(arrived, total)
datamatrix = [
["", "Nb. mois", "%"],
["Promptitude", on_time, pc_on_time],
["Complétude", arrived, pc_arrived],
]
table = generic_table(datamatrix)
text = "{} : {}".format(name, caption)
for widget in get_widgets_for(document, text, table, True):
section.append(widget)
# district report uses same widgets as region
WIDGET_DICT = import_path('snisi_malaria.indicators.'
'quarter_report.WIDGET_DICT',
failsafe=True)
#.........这里部分代码省略.........
示例12: get_caseload_completion_for
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
def get_caseload_completion_for(period, entity, uren):
periods = MonthPeriod.all_from(
MonthPeriod.find_create_from(period.middle().year, 1, 1), period)
field = '{}_comp_new_cases'.format(uren)
return compute_sum_value(entity=entity, periods=periods, field=field)
示例13: handle
# 需要导入模块: from snisi_core.models.Periods import MonthPeriod [as 别名]
# 或者: from snisi_core.models.Periods.MonthPeriod import all_from [as 别名]
def handle(self, *args, **options):
{
# 13
'01-04-2014': (1, 0),
'02-04-2014': (1, 0),
'03-04-2014': (1, 1),
'04-04-2014': (1, 0),
# 14
'05-04-2014': (1, 0),
'06-04-2014': (1, 0),
# 15
'17-04-2014': (1, 1),
# 17
'26-04-2014': (1, 1),
# 19
'08-05-2014': (1, 1),
'09-05-2014': (1, 0),
# 32
'12-08-2014': (1, 0),
'13-08-2014': (1, 0),
# 35
'03-09-2014': (1, 1),
'04-09-2014': (1, 1),
'05-09-2014': (1, 1),
# 37
'13-09-2014': (1, 0),
}
weeks_data = {
'eW13-2014': (4, 1),
'eW14-2014': (2, 0),
'eW15-2014': (1, 1),
'eW17-2014': (1, 1),
'eW19-2014': (2, 1),
'eW32-2014': (2, 0),
'eW35-2014': (3, 3),
'eW37-2014': (1, 0),
}
months_data = {
'04-2014': (8, 3),
'05-2014': (2, 1),
'06-2014': (0, 0),
'07-2014': (0, 0),
'08-2014': (2, 0),
'09-2014': (4, 3),
}
expected_dict = {
'entity': Entity.get_or_none("mali"),
'period': None,
'within_period': False,
'within_entity': False,
'reporting_role': Role.get_or_none("charge_sis"),
'reporting_period': None,
'extended_reporting_period': None,
'amount_expected': ExpectedReporting.EXPECTED_SINGLE
}
reportcls_epi = ReportClass.get_or_none(
'epidemio_weekly_routine_aggregated')
provider = Provider.get_or_none("autobot")
start_week = EpiWeekPeriod.find_create_by_date(
datetime.datetime(2014, 4, 1))
end_week = EpiWeekPeriod.find_create_by_date(
datetime.datetime(2014, 9, 20))
weeks = EpiWeekPeriod.all_from(start_week, end_week)
start_month = MonthPeriod.from_url_str("04-2014")
end_month = MonthPeriod.from_url_str("09-2014")
months = MonthPeriod.all_from(start_month, end_month)
logger.info("Removing all ExpectedReporting...")
ExpectedReporting.objects.filter(report_class=reportcls_epi).delete()
logger.info("Removing all EpidemiologyR, AggEpidemiologyR...")
EpidemiologyR.objects.all().delete()
AggEpidemiologyR.objects.all().delete()
def create_for(period, nb_cases, nb_deaths, periodcls=EpiWeekPeriod):
checker = EpidemiologyRIntegrityChecker()
checker.report_class = reportcls_epi
checker.period_class = periodcls
checker.set('year', period.end_on.year)
checker.set('month', period.end_on.month)
checker.set('day', period.end_on.day)
for key in AggEpidemiologyR.data_fields():
checker.set(key, 0)
checker.set('ebola_case', suspected)
checker.set('ebola_death', death)
#.........这里部分代码省略.........