def mk_notifiable_disease_alert(disease, alert_type, reporting_period, val, loc): notif = Notification(alert_type=alert_type) notif.uid = 'disease_%s_%s_%s' % (disease, reporting_period, loc.code) notif.text = '%d cases of %s reported in %s %s' % (val, disease, loc.name, loc.type.name) notif.url = None notif.originating_location = loc return notif
def mk_notifiable_disease_alert2(disease, alert_type, reporting_period, loc, district_data): notif = Notification(alert_type=alert_type) rr = "%s_%s" % (reporting_period[0].date().strftime('%F'), reporting_period[0].strftime('%H:%M-') + reporting_period[1].strftime('%H:%M')) notif.uid = 'disease_%s_%s_%s' % (disease, rr, loc.code) txt = "Urgent - " has_cases = False for d in district_data['data'].values(): if d['val'] > 0: has_cases = True txt += "%s at %s %s reported %s cases of %s" % (','.join(d['reporters']), d['name'], d['type'], d['val'], disease) if has_cases: notif.text = txt notif.sms_text = txt else: notif.text = '' notif.url = None notif.originating_location = loc return notif