0

How do I negate a statement? https://pypi.org/project/durable-rules/

I would like something like this but the ! doesn't work.

with ruleset('awv'):
    @when_all(m.visits.anyItem(item.cpt_codes.anyItem( item.matches('G0438') | item.matches('G0439') )))
    def had_awv_exam_or_awv_visit_more_than_12_month(c):
        print('had_awv_exam_or_awv_visit_more_than_12_month')
    @when_all(m.visits.anyItem(!item.cpt_codes.anyItem( item.matches('G0438') | item.matches('G0439') )))
    def never_awv_exam_or_awv_visit(c):
        print('no_awv_exam_or_awv_visit')
mkrieger1
  • 19,194
  • 5
  • 54
  • 65
vee
  • 680
  • 1
  • 10
  • 27

1 Answers1

1

Maybe - is what you are searching for... At least it looks like that to some extend in the documentation, but I don't know enough about the framework to tell whether it really does what you want.

If it doesn't, I'd suggest to manually negate your statement:

@when_all(m.visits.anyItem( item.cpt_codes.allItems( (item != "G0438") & (item != "G0439") ) ))
cherrywoods
  • 1,284
  • 1
  • 7
  • 18
  • Traceback (most recent call last): File "C:\Users\valerio\Documents\excelsior-atl\backend\cronjobs\awv.py", line 85, in @when_all(m.visits.anyItem(item.cpt_codes.allItems( item != 'G0438' & item != 'G0439' ))) TypeError: unsupported operand type(s) for &: 'str' and 'value' – vee Nov 03 '22 at 22:22
  • Some brackets were missing, edited. – cherrywoods Nov 04 '22 at 09:25