Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

How to Evaluate/Fix Common Expression Errors (Eval tokens)

This page explains errors in evaluating expressions added in label format, edit check rules, print rules etc., These are advanced Eval tokens used by clients catering their customized needs.

There are multiple levels available for users to configure the specimen label format, please read the wiki page to know more : Specimen Label Format.

Once you have identified at which level we are facing the issue, we can start breaking down the expression to find out the issues.

Examples :

1. Property or Field cannot be found in null

Error: OpenSpecimenException: Error evaluating the expression: #specimen.visit.clinicalStatus.value. Error: SpelEvaluationException: EL1007E: Property or field 'value' cannot be found in null

This type of error occurs when system attempts to retrieve value of an empty field. This expression expects a value stored for the field and cannot accept null value. In the above example, system is attempting to retrieve the clinical status of the visit associated which is empty.

Solution:

If the token is for an optional field, always use null safe operators (?.).
E.g.: eval("TreatmentType",#specimen?.visit?.clinicalStatus?.value).

2. Index 'n' invalid

Error evaluating the expression: #specimen.parentSpecimen.label.split('\.')[1]. Error: SpelEvaluationException: EL1024E: The array has '1' elements, index '1' is invalid.

This type of token is used when specimen label needs to extract substring after a separator e.g., dot (.) from parent specimen label. If there is no separator or text after the separator, system cannot extract a second part.

Solution: Ensure the parent specimen label has text after the separator (.)

3. StringIndexOutOfBoundsException

This type of token is used to extract the substring from the start of the label up to the second occurrence of the underscore. For example, if the parent specimen label is "Parent_LabelText_01", it will extract "Parent_LabelText".

If system doesn't find any of the 2 underscores in parent specimen label, it returns -1. This leads to an invalid range in the substring method giving the StringIndexOutOfBoundsException.

In the above error message, end -1 indicates that the second underscore was not present in the parent specimen label.

Solution: Ensure the parent specimen label contains at least two underscores.

Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com