I'm very new to the FHIR standard and I could use some help figuring out how to evaluate a ruleExpression against an object.
Here is my object:
@ResourceDef(name = "TestObj", profile = "http://hl7.org/fhir/StructureDefinition/TestObj")
@Data
public class TestObj extends DomainResource {
private static final long serialVersionUID = 1L;
@Child(name = "numMarbles")
@Extension(url = "http://hl7.org/fhir/CustomExtension/numMarbles", definedLocally = true, isModifier = false)
@Description(shortDefinition = "The number of marbles I have in my pocket")
private IntegerType numMarbles;
}
I'm trying to figure out how to run a rule evaluation on it. For example:
String ruleExp = "%numMarbles > 3"
In order to try options.. I've setup the following integration test:
@Test
void doRuleEval() throws Exception {
TestObj t = new TestObj();
t.setNumMarbles(4);
String ruleExp = "%numMarbles > '3'";
FhirPathR4 path = new FhirPathR4(fhirContext);
// ?????
Object something = path.evaluate(t, ruleExp, null);
// Line above always fails: "unknown fixed constant %numMarbles"
log.info("something: " + something.toString());
}
I've scoured the FHIR documentation and can't find java examples for how to evaluate dynamic rules against FHIR models. In the Javascript library we used the "compile" method but I can't find the equivalent Java method.
I feel like I'm missing something fundamental here.
The "evaluate" method is not documented - it takes in an "IBase" object which is any FHIR object from what I can tell, and returns some sort of list... who knows.
The FhirPathR4 object also contains a "parse" method that returns nothing and is also un-documented.
Thanks for any help or tips to point me in the right direction for evaluating a "ruleExpression" against an object's fields.