How to Write the Dynamic Logic Derivation Rule

Scenario

When the claim line procedure is equal to 38.01, modifier 51 is added

Dynamic Logic Unit

log.debug('procedure=' + claimLine.procedure?.code)

if (claimLine.procedure?.code == '38.01') {
   log.debug('add modifier')
   claimLine.addModifier('51')
}

Test Unit 1

This test case verifies that nothing is added when the procedure is not equal to 38.01.

//Use case: procedure code is different, so no modifier added

def claimLine = new ClaimLine()
def procedure = new Procedure();
procedure.code = '40.01'
claimLine.procedure=procedure

// call the UUT with the test person
def result = test( "DER_RULE_CLAIM_LINE_EX_1", [
    "claimLine" : claimLine
])

assert claimLine.claimLineModifierList.size() == 0
true

Test Unit 2

This test case verifies that modifier 51 added when the procedure is equal to 38.01.

//Use case: procedure code is set, so modifier added

def claimLine = new ClaimLine()
def procedure = new Procedure();
procedure.code = '38.01'
claimLine.procedure=procedure

// call the UUT with the test person
def result = test( "DER_RULE_CLAIM_LINE_EX_1", [
    "claimLine" : claimLine
])

assert claimLine.claimLineModifierList[0].modifier.code == '51'
true