Exemplo n.º 1
0
def run_rules(data):
    """Mandatory function which runs the rules pertaining
        to this module

    """
    form = Form(data)
    for event in form.events():
        for field in event.fields():
            field_value = field.value
            if not field_value:
                continue
            else:
                is_cancelled = False
                is_cancelled = process_field_cancelled_value(field_value)
                if is_cancelled is True:
                    # clear the field value
                    field.clear_value()
                else:
                    continue
    return form
Exemplo n.º 2
0
    def test_is_not_empty(self):
        raw_xml = """
            <person_form_event>
              <person>
                <study_id>60</study_id>
                <all_form_events>
                  <form>
                    <name>hcv_rna_results</name>
                    <event>
                      <name>1_arm_1</name>
                      <field><name/><value>o hai</value></field>
                      <field><name>hcv_lbdtc</name><value/></field>
                    </event>
                  </form>
                </all_form_events>
              </person>
            </person_form_event>"""

        form = Form(etree.fromstring(raw_xml))
        event = form.events().next()

        self.assertFalse(event.is_empty())