예제 #1
0
def ruleHelpRfgp(request):
    my_file = Path("./diagnostics/custom_variables_p.py")
    if my_file.is_file():
        module = import_module('.custom_variables_p',package="diagnostics")
        data = export_rule_data(module.CustomPatientVariables, PatientActions)
        return HttpResponse(json.dumps(data), content_type="application/json")
    else:
        data = export_rule_data(PatientVariables, PatientActions)
        return HttpResponse(json.dumps(data), content_type="application/json")
예제 #2
0
def ruleHelpMar(request):
    my_file = Path("./monitoring/custom_variables_m.py")
    if my_file.is_file():
        module = import_module('.custom_variables_m',package="monitoring")
        data = export_rule_data(module.CustomMonitoringVariables, MonitoringActions)
        return HttpResponse(json.dumps(data), content_type="application/json")
    else:
        data = export_rule_data(MonitoringVariables, MonitoringActions)
        return HttpResponse(json.dumps(data), content_type="application/json")
 def _get_rule_data(cls):
     rule_data = utils.export_rule_data(cls.variables, cls.actions)
     return json.dumps(rule_data)
예제 #4
0
def test_export_rule_data():
    """
    Tests that export_rule_data has the three expected keys in the right format.
    """
    all_data = utils.export_rule_data(SomeVariables(), SomeActions())
    assert all_data.get("actions") == [{
        "name":
        "some_action",
        "label":
        "Some Action",
        "params": [{
            'bypass_validator': False,
            'fieldType': 'numeric',
            'label': 'Foo',
            'name': 'foo'
        }]
    }, {
        "name":
        "some_other_action",
        "label":
        "woohoo",
        "params": [{
            'bypass_validator': False,
            'fieldType': 'text',
            'label': 'Bar',
            'name': 'bar'
        }]
    }, {
        "name":
        "some_select_action",
        "label":
        "Some Select Action",
        "params": [{
            'fieldType':
            fields.FIELD_SELECT,
            'name':
            'baz',
            'label':
            'Baz',
            'options': [{
                'label': 'Chose Me',
                'name': 'chose_me'
            }, {
                'label': 'Or Me',
                'name': 'or_me'
            }]
        }]
    }]

    assert all_data.get("variables") == [
        {
            "name": "foo",
            "label": "Foo",
            "field_type": "string",
            "options": [],
            "params": []
        },
        {
            'name': 'rule_received',
            'label': 'Rule Received',
            'field_type': 'boolean',
            'options': [],
            'params': [],
        },
        {
            "name": "ten",
            "label": "Diez",
            "field_type": "numeric",
            "options": [],
            "params": []
        },
        {
            'name': 'true_bool',
            'label': 'True Bool',
            'field_type': 'boolean',
            'options': [],
            "params": []
        },
        {
            'name': 'x_plus_one',
            'label': 'X Plus One',
            'field_type': 'numeric',
            'options': [],
            'params': [{
                'field_type': 'numeric',
                'name': 'x',
                'label': 'X'
            }]
        },
    ]

    assert all_data.get("variable_type_operators") == {
        'boolean': [{
            'input_type': 'none',
            'label': 'Is False',
            'name': 'is_false'
        }, {
            'input_type': 'none',
            'label': 'Is True',
            'name': 'is_true'
        }],
        'datetime': [
            {
                'input_type': FIELD_DATETIME,
                'label': 'After Than',
                'name': 'after_than'
            },
            {
                'input_type': FIELD_DATETIME,
                'label': 'After Than Or Equal To',
                'name': 'after_than_or_equal_to'
            },
            {
                'input_type': FIELD_DATETIME,
                'label': 'Before Than',
                'name': 'before_than'
            },
            {
                'input_type': FIELD_DATETIME,
                'label': 'Before Than Or Equal To',
                'name': 'before_than_or_equal_to'
            },
            {
                'input_type': FIELD_DATETIME,
                'label': 'Equal To',
                'name': 'equal_to'
            },
        ],
        'date': [
            {
                'input_type': FIELD_DATE,
                'label': 'After Than',
                'name': 'after_than'
            },
            {
                'input_type': FIELD_DATE,
                'label': 'After Than Or Equal To',
                'name': 'after_than_or_equal_to'
            },
            {
                'input_type': FIELD_DATE,
                'label': 'Before Than',
                'name': 'before_than'
            },
            {
                'input_type': FIELD_DATE,
                'label': 'Before Than Or Equal To',
                'name': 'before_than_or_equal_to'
            },
            {
                'input_type': FIELD_DATE,
                'label': 'Equal To',
                'name': 'equal_to'
            },
        ],
        'numeric': [{
            'input_type': 'numeric',
            'label': 'Equal To',
            'name': 'equal_to'
        }, {
            'input_type': 'numeric',
            'label': 'Greater Than',
            'name': 'greater_than'
        }, {
            'input_type': 'numeric',
            'label': 'Greater Than Or Equal To',
            'name': 'greater_than_or_equal_to'
        }, {
            'input_type': 'numeric',
            'label': 'Less Than',
            'name': 'less_than'
        }, {
            'input_type': 'numeric',
            'label': 'Less Than Or Equal To',
            'name': 'less_than_or_equal_to'
        }],
        'select': [{
            'input_type': 'select',
            'label': 'Contains',
            'name': 'contains'
        }, {
            'input_type': 'select',
            'label': 'Does Not Contain',
            'name': 'does_not_contain'
        }],
        'select_multiple': [{
            'input_type': 'select_multiple',
            'label': 'Contains All',
            'name': 'contains_all'
        }, {
            'input_type': 'select_multiple',
            'label': 'Is Contained By',
            'name': 'is_contained_by'
        }, {
            'input_type': 'select_multiple',
            'label': 'Shares At Least One Element With',
            'name': 'shares_at_least_one_element_with'
        }, {
            'input_type': 'select_multiple',
            'label': 'Shares Exactly One Element With',
            'name': 'shares_exactly_one_element_with'
        }, {
            'input_type': 'select_multiple',
            'label': 'Shares No Elements With',
            'name': 'shares_no_elements_with'
        }],
        'string': [{
            'input_type': 'text',
            'label': 'Contains',
            'name': 'contains'
        }, {
            'input_type': 'text',
            'label': 'Ends With',
            'name': 'ends_with'
        }, {
            'input_type': 'text',
            'label': 'Equal To',
            'name': 'equal_to'
        }, {
            'input_type': 'text',
            'label': 'Equal To (case insensitive)',
            'name': 'equal_to_case_insensitive'
        }, {
            'input_type': 'text',
            'label': 'Matches Regex',
            'name': 'matches_regex'
        }, {
            'input_type': 'none',
            'label': 'Non Empty',
            'name': 'non_empty'
        }, {
            'input_type': 'text',
            'label': 'Starts With',
            'name': 'starts_with'
        }],
        'time': [
            {
                'input_type': FIELD_TIME,
                'label': 'After Than',
                'name': 'after_than'
            },
            {
                'input_type': FIELD_TIME,
                'label': 'After Than Or Equal To',
                'name': 'after_than_or_equal_to'
            },
            {
                'input_type': FIELD_TIME,
                'label': 'Before Than',
                'name': 'before_than'
            },
            {
                'input_type': FIELD_TIME,
                'label': 'Before Than Or Equal To',
                'name': 'before_than_or_equal_to'
            },
            {
                'input_type': FIELD_TIME,
                'label': 'Equal To',
                'name': 'equal_to'
            },
        ],
    }
 def test_should_export_product_rule_data(self):
     actual = export_rule_data(ProductVariables, ProductActions)
     expected = self._get_rule_data()
     self.assertEqual(actual, expected)
예제 #6
0
def ruleHelpDdbosr(request):
    data = export_rule_data(DiseasesVariables, DiseasesActions)
    return HttpResponse(json.dumps(data), content_type="application/json")
예제 #7
0
def ruleHelpFdsr(request):
    data = export_rule_data(SyndromeVariables, SyndromeActions)
    return HttpResponse(json.dumps(data), content_type="application/json")
예제 #8
0
def ruleHelpPadr(request):
    data = export_rule_data(AlergyVariables, AlergyActions)
    return HttpResponse(json.dumps(data), content_type="application/json")