def report_config(self): config = dict( domain=self.domain, empty="", yes="yes", no="no", death="death", pregnant_mother_type="pregnant", health_center="health_center", hospital="hospital", home="home", on_route="on_route", other="other", male="male", female="female", health_center_worker="health_center_worker", trained_traditional_birth_attendant="trained_traditional_birth_attendant", normal_delivery="normal", cesarean_delivery="cesarean", unknown_delivery="unknown", abortion="abortion", weight_birth_25="2.5", newborn_death="newborn_death", infant_death="infant_death", child_death="child_death", date_of_death="date_of_death", ) if "startdate" in self.request.GET and self.request.GET["startdate"]: config["startdate"] = self.request.GET["startdate"] config["strsd"] = self.request.GET["startdate"] if "enddate" in self.request.GET and self.request.GET["enddate"]: config["enddate"] = self.request.GET["enddate"] config["stred"] = self.request.GET["enddate"] today = datetime.date.today() config["today"] = json_format_date(today) for d in [35, 56, 84, 85, 112, 196]: config["today_plus_%d" % d] = json_format_date(today + datetime.timedelta(days=d)) for d in [2, 4, 21, 25, 40, 42, 75, 106, 182, 183, 273, 365, 547, 548, 700, 730]: config["today_minus_%d" % d] = json_format_date(today - datetime.timedelta(days=d)) for d in [1, 3, 5, 6]: config["%d" % d] = "%d" % d config["last_month"] = json_format_date(today - datetime.timedelta(days=30)) for k, v in sorted(LOCATION_HIERARCHY.iteritems(), reverse=True): req_prop = "location_%s" % v["prop"] if self.request.GET.getlist(req_prop, []): location_list = self.request.GET.getlist(req_prop, []) if location_list and location_list[0] != "0": config.update({k: tuple(location_list)}) return config
def report_config(self): config = dict( domain=self.domain, empty='', yes='yes', no='no', death='death', pregnant_mother_type = 'pregnant', health_center = 'health_center', hospital = 'hospital', home = 'home', on_route = 'on_route', other = 'other', male = 'male', female = 'female', health_center_worker = 'health_center_worker', trained_traditional_birth_attendant = 'trained_traditional_birth_attendant', normal_delivery = 'normal', cesarean_delivery = 'cesarean', unknown_delivery = 'unknown', abortion = 'abortion', weight_birth_25='2.5', newborn_death='newborn_death', infant_death='infant_death', child_death='child_death', date_of_death='date_of_death' ) if 'startdate' in self.request.GET and self.request.GET['startdate']: config['startdate'] = self.request.GET['startdate'] config['strsd'] = self.request.GET['startdate'] if 'enddate' in self.request.GET and self.request.GET['enddate']: config['enddate'] = self.request.GET['enddate'] config['stred'] = self.request.GET['enddate'] today = datetime.date.today() config['today'] = json_format_date(today) for d in [35, 56, 84, 85, 112, 196]: config['today_plus_%d' % d] = json_format_date(today + datetime.timedelta(days=d)) for d in [2, 4, 21, 25, 40, 42, 75, 106, 182, 183, 273, 365, 547, 548, 700, 730]: config['today_minus_%d' % d] = json_format_date(today - datetime.timedelta(days=d)) for d in [1, 3, 5, 6]: config['%d' % d] = '%d' % d config['last_month'] = json_format_date(today - datetime.timedelta(days=30)) for k, v in sorted(LOCATION_HIERARCHY.iteritems(), reverse=True): req_prop = 'location_%s' % v['prop'] if self.request.GET.getlist(req_prop, []): location_list = self.request.GET.getlist(req_prop, []) if location_list and location_list[0] != '0': config.update({k: tuple(location_list)}) return config
def report_config(self): config = dict( domain=self.domain, empty='', yes='yes', no='no', death='death', pregnant_mother_type = 'pregnant', health_center = 'health_center', hospital = 'hospital', home = 'home', on_route = 'on_route', other = 'other', health_center_worker = 'health_center_worker', trained_traditional_birth_attendant = 'trained_traditional_birth_attendant', normal_delivery = 'normal', cesarean_delivery = 'cesarean', unknown_delivery = 'unknown', abortion = 'abortion', weight_birth_25 = '2.5' ) if 'startdate' in self.request.GET and self.request.GET['startdate']: config['startdate'] = self.request.GET['startdate'] config['strsd'] = self.request.GET['startdate'] if 'enddate' in self.request.GET and self.request.GET['enddate']: config['enddate'] = self.request.GET['enddate'] config['stred'] = self.request.GET['enddate'] today = datetime.date.today() config['today'] = today.strftime("%Y-%m-%d") for d in [2, 5, 21, 40, 75, 84, 106, 168, 182, 183, 195, 224, 245, 273, 365, 547, 548, 700, 730]: config['days_%d' % d] = (today - datetime.timedelta(days=d)).strftime("%Y-%m-%d") for d in [1, 3, 5, 6]: config['%d' % d] = '%d' % d config['last_month'] = (today - datetime.timedelta(days=30)).strftime("%Y-%m-%d") config['first_trimester_start_date'] = (today - datetime.timedelta(days=84)).strftime("%Y-%m-%d") config['second_trimester_start_date'] = (today - datetime.timedelta(days=84)).strftime("%Y-%m-%d") config['second_trimester_end_date'] = (today - datetime.timedelta(days=196)).strftime("%Y-%m-%d") config['third_trimester_start_date'] = (today - datetime.timedelta(days=196)).strftime("%Y-%m-%d") for k, v in sorted(LOCATION_HIERARCHY.iteritems(), reverse=True): req_prop = 'location_%s' % v['prop'] if self.request.GET.getlist(req_prop, []): location_list = self.request.GET.getlist(req_prop, []) if location_list and location_list[0] != '0': config.update({k: tuple(location_list)}) break return config
def drilldown_map(self): hierarchy = helper = [] hierarchy_config = sorted([k for k in LOCATION_HIERARCHY.keys()]) data = LocationSqlData(self.request.domain).get_data() for val in data: for lvl in hierarchy_config: tmp = dict(val=val[lvl], text=val[lvl], next=[]) tmp_next = [] exist = False for item in hierarchy: if item['val'] == val[lvl]: exist = True tmp_next = item['next'] break if not exist: if not hierarchy: hierarchy.append(dict(val=0, text='All', next=[])) hierarchy.append(tmp) hierarchy = tmp['next'] else: hierarchy = tmp_next hierarchy = helper return hierarchy
def get_labels(self): return [(v['name'], v['prop']) for k,v in sorted(LOCATION_HIERARCHY.iteritems())]
def get_labels(self): return [(v['name'], v['prop']) for k, v in sorted(LOCATION_HIERARCHY.iteritems())]
def report_config(self): config = dict(domain=self.domain, empty='', yes='yes', no='no', death='death', pregnant_mother_type='pregnant', health_center='health_center', hospital='hospital', home='home', on_route='on_route', other='other', health_center_worker='health_center_worker', trained_traditional_birth_attendant= 'trained_traditional_birth_attendant', normal_delivery='normal', cesarean_delivery='cesarean', unknown_delivery='unknown', abortion='abortion', weight_birth_25='2.5') if 'startdate' in self.request.GET and self.request.GET['startdate']: config['startdate'] = self.request.GET['startdate'] config['strsd'] = self.request.GET['startdate'] if 'enddate' in self.request.GET and self.request.GET['enddate']: config['enddate'] = self.request.GET['enddate'] config['stred'] = self.request.GET['enddate'] today = datetime.date.today() config['today'] = today.strftime("%Y-%m-%d") for d in [ 2, 5, 21, 40, 75, 84, 106, 168, 182, 183, 195, 224, 245, 273, 365, 547, 548, 700, 730 ]: config['days_%d' % d] = (today - datetime.timedelta(days=d)).strftime("%Y-%m-%d") for d in [1, 3, 5, 6]: config['%d' % d] = '%d' % d config['last_month'] = ( today - datetime.timedelta(days=30)).strftime("%Y-%m-%d") config['first_trimester_start_date'] = ( today - datetime.timedelta(days=84)).strftime("%Y-%m-%d") config['second_trimester_start_date'] = ( today - datetime.timedelta(days=84)).strftime("%Y-%m-%d") config['second_trimester_end_date'] = ( today - datetime.timedelta(days=196)).strftime("%Y-%m-%d") config['third_trimester_start_date'] = ( today - datetime.timedelta(days=196)).strftime("%Y-%m-%d") for k, v in sorted(LOCATION_HIERARCHY.iteritems(), reverse=True): req_prop = 'location_%s' % v['prop'] if self.request.GET.getlist(req_prop, []): location_list = self.request.GET.getlist(req_prop, []) if location_list and location_list[0] != '0': config.update({k: tuple(location_list)}) break return config
def report_config(self): config = dict(domain=self.domain, empty='', yes='yes', no='no', death='death', pregnant_mother_type='pregnant', health_center='health_center', hospital='hospital', home='home', on_route='on_route', other='other', male='male', female='female', health_center_worker='health_center_worker', trained_traditional_birth_attendant= 'trained_traditional_birth_attendant', normal_delivery='normal', cesarean_delivery='cesarean', unknown_delivery='unknown', abortion='abortion', weight_birth_25='2.5', newborn_death='newborn_death', infant_death='infant_death', child_death='child_death', date_of_death='date_of_death') if 'startdate' in self.request.GET and self.request.GET['startdate']: config['startdate'] = self.request.GET['startdate'] config['strsd'] = self.request.GET['startdate'] if 'enddate' in self.request.GET and self.request.GET['enddate']: config['enddate'] = self.request.GET['enddate'] config['stred'] = self.request.GET['enddate'] today = datetime.date.today() config['today'] = json_format_date(today) for d in [35, 56, 84, 85, 112, 196]: config['today_plus_%d' % d] = json_format_date(today + datetime.timedelta(days=d)) for d in [ 2, 4, 21, 25, 40, 42, 75, 106, 182, 183, 273, 365, 547, 548, 700, 730 ]: config['today_minus_%d' % d] = json_format_date(today - datetime.timedelta(days=d)) for d in [1, 3, 5, 6]: config['%d' % d] = '%d' % d config['last_month'] = json_format_date(today - datetime.timedelta(days=30)) for k, v in sorted(LOCATION_HIERARCHY.iteritems(), reverse=True): req_prop = 'location_%s' % v['prop'] if self.request.GET.getlist(req_prop, []): location_list = self.request.GET.getlist(req_prop, []) if location_list and location_list[0] != '0': config.update({k: tuple(location_list)}) return config