Exemplo n.º 1
0
def test_contains_expression(engine):
    """ """
    term = T_("Organization.id")
    value = V_("01")
    term = contains_(term, value)
    term.finalize(engine)

    assert term.comparison_operator == OPERATOR.contains
Exemplo n.º 2
0
def test_sa_expression(engine):
    """ """
    term = T_("Organization.id")
    value = V_("f0")
    term = sa_(term, value)
    term.finalize(engine)

    assert term.comparison_operator == OPERATOR.sa
Exemplo n.º 3
0
def test_complex_expression(engine):
    """ """
    term = T_("Organization.telecom.rank")
    value = V_("26")
    term = term >= (-value)
    term.finalize(engine)

    assert term.unary_operator == OPERATOR.neg
Exemplo n.º 4
0
def test_expression_existence(engine):
    """ """
    term = exists_("Patient.name.period.start")
    term.finalize(engine)

    assert IExistsTerm.providedBy(term) is True
    assert term.unary_operator == OPERATOR.pos

    # test not exists
    term = not_exists_("Task.for.reference")
    term.finalize(engine)
    assert term.unary_operator == OPERATOR.neg

    # Test from Term
    term = T_("Task.for.reference")
    term = exists_(term)
    term.finalize(engine)

    assert IExistsTerm.providedBy(term) is True
Exemplo n.º 5
0
def test_expression_or(engine):
    """ """
    term = or_("Task.for.reference", "Patient/PAT-001")
    term.finalize(engine)
    assert ITerm.providedBy(term)
    assert term.arithmetic_operator == OPERATOR.or_
    assert term.path.context.parent.prop_name == "for_fhir"

    term = T_("Patient.name.period.start")

    term = or_(-term, datetime.now().isoformat(timespec="seconds"))
    term.finalize(engine)
    assert term.unary_operator == OPERATOR.neg

    term = T_("Patient.name.period.start")
    group = G_(term <= datetime.now().isoformat(timespec="seconds"))
    group = or_(group)

    group.finalize(engine)

    assert len(group.terms) == 1
    assert group.terms[0]._finalized is True
Exemplo n.º 6
0
def test_expression_add(engine):
    """ """
    term = and_("Patient.name.given", "Krog")
    term.finalize(engine)
    assert ITerm.providedBy(term)
    assert term.arithmetic_operator == OPERATOR.and_
    assert term.path.context.multiple is True

    term = T_("Patient.name.period.start")
    term = and_(-term, datetime.now().isoformat(timespec="seconds"))
    term.finalize(engine)
    assert term.unary_operator == OPERATOR.neg

    term = T_("Patient.name.period.start")
    group = G_(term <= datetime.now().isoformat(timespec="seconds"))
    group = and_(group)

    group.finalize(engine)

    assert IGroupTerm.providedBy(group) is True
    assert len(group.terms) == 1
    assert group.terms[0]._finalized is True