def get_beneficiary_details(case_id, awc_id, selected_month): selected_month = datetime(*selected_month) six_month_before = selected_month - relativedelta(months=6) data = ChildHealthMonthlyView.objects.filter( case_id=case_id, awc_id=awc_id, month__range=(six_month_before, selected_month)).order_by('month') min_height = 35 max_height = 120.0 beneficiary = {'weight': [], 'height': [], 'wfl': []} for row in data: age_in_months = row.age_in_months recorded_weight = row.recorded_weight recorded_height = row.recorded_height beneficiary.update({ 'person_name': row.person_name, 'mother_name': row.mother_name, 'dob': row.dob, 'age': current_age(row.dob, datetime.now().date()), 'sex': row.sex, 'age_in_months': age_in_months, }) if age_in_months <= 60: if recorded_weight: beneficiary['weight'].append({ 'x': int(age_in_months), 'y': float(recorded_weight) }) if recorded_height: beneficiary['height'].append({ 'x': int(age_in_months), 'y': float(recorded_height) }) if recorded_height and min_height <= recorded_height <= max_height: beneficiary['wfl'].append({ 'x': float(row.recorded_height), 'y': float(recorded_weight) if row.recorded_height else 0 }) return beneficiary
def get_beneficiary_details(domain, case_id): data = get_growth_monitoring_details(domain, case_id) min_height = 45 max_height = 120.0 beneficiary = { 'weight': [], 'height': [], 'wfl': [] } for row in data: age_in_months = row[5] recorded_weight = row[6] recorded_height = row[7] beneficiary.update({ 'person_name': row[1], 'mother_name': row[2], 'dob': row[3], 'age': current_age(row[3], datetime.now().date()), 'sex': row[4], 'age_in_months': row[5], }) if age_in_months <= 60: if recorded_weight: beneficiary['weight'].append({ 'x': int(age_in_months), 'y': float(recorded_weight) }) if recorded_height: beneficiary['height'].append({ 'x': int(age_in_months), 'y': float(recorded_height) }) if recorded_height and min_height <= recorded_height <= max_height: beneficiary['wfl'].append({ 'x': float(row.recorded_height), 'y': float(recorded_weight) if row.recorded_height else 0 }) return beneficiary
def get_beneficiary_details(case_id): data = ChildHealthMonthlyView.objects.filter( case_id=case_id).order_by('month') min_height = 45 max_height = 120.0 beneficiary = {'weight': [], 'height': [], 'wfl': []} for row in data: beneficiary.update({ 'person_name': row.person_name, 'mother_name': row.mother_name, 'dob': row.dob, 'age': current_age(row.dob, datetime.now().date()), 'sex': row.sex, 'age_in_months': row.age_in_months, }) if row.age_in_months <= 60: if row.recorded_weight: beneficiary['weight'].append({ 'x': int(row.age_in_months), 'y': float(row.recorded_weight) }) if row.recorded_height: beneficiary['height'].append({ 'x': int(row.age_in_months), 'y': float(row.recorded_height) }) if row.recorded_height and min_height <= row.recorded_height <= max_height: if row.recorded_height: beneficiary['wfl'].append({ 'x': float(row.recorded_height), 'y': float(row.recorded_weight) if row.recorded_height else 0 }) return beneficiary