LinuxForHealth / hl7v2-fhir-converter

Converts HL7 v2 Messages to FHIR Resources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Only GeneralUtils available as JEXL in a variable definition

PatriciaPerozoUSDS opened this issue · comments

Describe the bug
In extensionMeta.yml, extension_4 calls GeneralUtils within a variable definition

vars:
    value: MSH.7, GeneralUtils.dateTimeWithZoneId(value,ZONEID)

None of the other classes available in the explicit JEXL definition (String, StringUtils, NumberUtils) work in this style of declaration.

To Reproduce

  • Replace the above with
vars:
    value: MSH.7, String.format("%s", value)
  • run the converter
  • get error ERROR io.github.linuxforhealth.hl7.resource.deserializer.HL7DataBasedResourceDeserializer - deserialization failure expression type RESOURCE

Expected behavior
I would expect if GeneralUtils was available to be used as a part of variable definition, that the other classes initialized in the JEXLEngineUtil constructor would be available too.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS Big Sur
  • Version 1.0.18

Additional context
Add any other context about the problem here.

@PatriciaPerozoUSDS
Looking into the code over your concerns, I don’t see an easy way to enable anything other than GeneralUtils for JEXL handling. I am investigating further with some of the other developers, but it could take a while.



In the mean time, can you explain what it is you’re trying to accomplish? Perhaps there is some other way to do what you want to do.

Hi @cragun47 - We were hoping to simplify OID generation by adding a line to one of our extensions like config below:

# Patient las update facility universal ID
extension_4:
  generateList: true
  valueOf: extension/Extension
  expressionType: resource
  condition: $idStr NOT_NULL && $systemStr EQUALS ISO
  vars:
    idStr: String, PID.34.2
    value: PID.34.2, "urn:oid:".concat(value)
    systemStr: String, PID.34.3
  constants:
    KEY_NAME_SUFFIX: Oid
    urlValue: last-updated-facility-universal-id

We have a way to define the extension above by defining a constant and then using value: $oidUrlPrefix + PID.34.2 instead but were looking for ways to use JEXL to simplify the config

Ideally, we would love to be able to add our own utilities class and add that as a usable expression in the same way GeneralUtils is used. Then we could define a makeOID function in the util class and use that everywhere we wanted to instead of the inline use above.

Ideally, we would love to be able to add our own utilities class and add that as a usable expression in the same way GeneralUtils is used. Then we could define a makeOID function in the util class and use that everywhere we wanted to instead of the inline use above.

I'm very much interested in adding this functionality. We would like to be able to supply our own utils classes which could then interrogate our FHIR server to lookup Resources such as ValueSets and ConceptMaps for use in the HL7 mapping of many of our custom segments to our IG.

I tracked down the reason why only GeneralUtils functions can be placed into variables:

There's special code in VariableGenerator - specifically targeted at GeneralUtils functions.

A stop-gap solution that allows for functions from any group (so long as that group name ends in Utils) is reletively easy.

    // Any custom function will work - so long as the group name ends in Utils  e.g.:
    //  vars
    //      value: PID.26 , MyCustomUtils.myCustomFunction(value)
    //
    if (StringUtils.contains(rawVariable, "Utils.")) {
      String[] values = rawVariable.split(",", 2);
      // Handle * in combination with GeneralUtils function
      exp = ExpressionAttributes.extractExpressionModifiers(values[0], false);
      if (values.length == COMPONENT_LENGTH_FOR_VAR_EXPRESSION) {
        List<String> specs = getTokens(exp.getExpression());
        return new ExpressionVariable(varName, values[1], specs, exp.getExtractMultiple(), exp.getRetainEmpty());
      }

I wonder if we can make the customFunctions Map easily available so we can check the map keys in VariableGenerator rather than brute-force it the way it is currently?

Keep an eye on #504 - we really need this to work.