(case_id, query_date, username=None)
return res
Actually run query for username submissions
    todo: do terms for the pact_ids instead of individual term?
Actually run query for username submissions
    todo: do terms for the pact_ids instead of individual term?
Actually run query for username submissions todo : do terms for the pact_ids instead of individual term?
def dots_submissions_by_case(case_id, query_date, username=None):
    """
    Actually run query for username submissions
    todo: do terms for the pact_ids instead of individual term?
    """
    xform_es = ReportFormESView(PACT_DOMAIN)
    script_fields = {
        "doc_id": get_report_script_field('_id', is_known=True),
        "pact_id": get_report_script_field("form.pact_id"),
        "encounter_date": get_report_script_field('form.encounter_date'),
        "username": get_report_script_field('form.meta.username', is_known=True),
        "visit_type": get_report_script_field('form.visit_type'),
        "visit_kept": get_report_script_field('form.visit_kept'),
        "contact_type": get_report_script_field('form.contact_type'),
        "observed_art": get_report_script_field('form.observed_art'),
        "observed_non_art": get_report_script_field('form.observed_non_art'),
        "observer_non_art_dose": get_report_script_field('form.observed_non_art_dose'),
        "observed_art_dose": get_report_script_field('form.observed_art_dose'),
        "pillbox_check": get_report_script_field('form.pillbox_check.check'),
        "scheduled": get_report_script_field('form.scheduled'),
    }

    term_block = {'form.#type': 'dots_form'}
    if username is not None:
        term_block['form.meta.username'] = username
    query = (
        get_by_case_id_form_es_query(0, 1, case_id)
        .filter(filters.range_filter('form.encounter_date.#value', gte=query_date, lte=query_date))
        .sort('received_on')
        .raw_query
    )
    query['script_fields'] = script_fields
    res = xform_es.run_query(query)
    print(json.dumps(res, indent=2))
    return res
def dots_submissions_by_case ( case_id , query_date , username = None ) : xform_es = ReportFormESView ( PACT_DOMAIN ) script_fields = { "doc_id" : get_report_script_field ( '_id' , is_known = True ) , "pact_id" : get_report_script_field ( "form.pact_id" ) , "encounter_date" : get_report_script_field ( 'form.encounter_date' ) , "username" : get_report_script_field ( 'form.meta.username' , is_known = True ) , "visit_type" : get_report_script_field ( 'form.visit_type' ) , "visit_kept" : get_report_script_field ( 'form.visit_kept' ) , "contact_type" : get_report_script_field ( 'form.contact_type' ) , "observed_art" : get_report_script_field ( 'form.observed_art' ) , "observed_non_art" : get_report_script_field ( 'form.observed_non_art' ) , "observer_non_art_dose" : get_report_script_field ( 'form.observed_non_art_dose' ) , "observed_art_dose" : get_report_script_field ( 'form.observed_art_dose' ) , "pillbox_check" : get_report_script_field ( 'form.pillbox_check.check' ) , "scheduled" : get_report_script_field ( 'form.scheduled' ) , } term_block = { 'form.#type' : 'dots_form' } if username is not None : term_block [ 'form.meta.username' ] = username query = ( get_by_case_id_form_es_query ( 0 , 1 , case_id ) . filter ( filters . range_filter ( 'form.encounter_date.#value' , gte = query_date , lte = query_date ) ) . sort ( 'received_on' ) . raw_query ) query [ 'script_fields' ] = script_fields res = xform_es . run_query ( query ) print ( json . dumps ( res , indent = 2 ) ) return res