Exemplo n.º 1
0
def save_collect(*form_cleaned_datas, test=False):

    contexts = Listorm(
        norm_context(form_data, verbosing='types')
        for form_data in form_cleaned_datas)

    dates = sorted(contexts.unique('date'))
    min_start_date, max_end_date = contexts.min('start_date'), contexts.max(
        'end_date')
    total_wards = sorted(
        set(
            reduce(lambda acc, elem: acc + elem,
                   contexts.column_values('wards'))))
    print('saving form data...')
    pprint(contexts)
    print('min_start_date: ', min_start_date)
    print('max_end_date: ', max_end_date)
    print('total_wards:', total_wards)
    print('tested:', test)
    collector = Collector()
    return collector.save(dates,
                          min_start_date,
                          max_end_date,
                          total_wards,
                          *contexts,
                          test=test)
Exemplo n.º 2
0
def get_drug_list_by_edi(*edi_codes, **kwargs):
    drug_list = Listorm()
    for edi in edi_codes:
        drug_list += get_drug_search_list(search_bohcode=edi)
    drug_codes = drug_list.column_values('drug_cd')
    detail_list = Listorm()
    for drug_code in drug_codes:
        detail_list += get_drug_detail(drug_code, **kwargs)
    ret = detail_list.join(drug_list, left_on='drug_code', right_on='drug_cd')
    return ret
Exemplo n.º 3
0
def get_drug_list(*criterias, **kwargs):
    drug_list = Listorm()
    for crit in tqdm(criterias, total=len(criterias)):
        drug_list += get_drug_search_list(**crit)
    drug_codes = drug_list.column_values('drug_cd')
    detail_list = Listorm()
    print('collecting {} items....'.format(len(drug_codes)))
    for drug_code in tqdm(drug_codes, total=len(drug_codes)):
        detail_list += get_drug_detail(drug_code, **kwargs)
    ret = detail_list.join(drug_list, left_on='drug_code', right_on='drug_cd')
    records = [dict(row) for row in ret]
    return records