Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support (R4B) to handle multiple source rules in a group #1466

Closed
wants to merge 3 commits into from

Conversation

brianpos
Copy link
Contributor

Add support for rules that have multiple source variables
(as noted in the spec here: https://www.hl7.org/fhir/mapping-language.html#7.8.0.8.1 )
e.g.

item.linkId as itemId, itemAnswer.value as coding
     -> condition.id = ('condition_' + %itemId.substring(1) + '_'+ %coding.code

The unit test requires some test files that are in the fhir-test-cases repo here:
FHIR/fhir-test-cases@master...brianpos:fhir-test-cases:master

This is only draft as I've only ported the change to the R4B branch, once conceptually approved, I will copy this change (and test) into R4 and R5.

@brianpos
Copy link
Contributor Author

Note that the test testMultipleSourceVariables passes and works.
However the very similar testMultipleSourceVariablesCopyId doesn't and gets a weird can't cast a StringType to an Id message: this is the rule that has the issue

item.linkId as itemId, itemAnswer.value as coding
   -> condition.id = ('condition_' + %itemId.substring(1) + '_'+ %coding.code)

…ent to summary())

And copy the unit tests for the other 2 engines
…s, and too many (and make the messages consistent between analyse and execute)
@bvdh
Copy link

bvdh commented Nov 24, 2023

Note that the test testMultipleSourceVariables passes and works. However the very similar testMultipleSourceVariablesCopyId doesn't and gets a weird can't cast a StringType to an Id message: this is the rule that has the issue

item.linkId as itemId, itemAnswer.value as coding
   -> condition.id = ('condition_' + %itemId.substring(1) + '_'+ %coding.code)

This might be caused by an issue in org.hl7.fhir.r5.model.TypeConvertor.
This class does not accept primitive types for many data classes. Updating castToId to

public static IdType castToId(Base b) throws FHIRException {
    if (b == null) {
      return null;
    }

    if (b instanceof IdType)
      return (IdType) b;
    else if ( b instanceof StringType )
      return ( new IdType( b.primitiveValue() ));
    else if (b.hasPrimitiveValue())
      return new IdType( b.primitiveValue() );
    else
      throw new FHIRException("Unable to convert a "+b.fhirType()+"("+b.getClass().getName()+") to a Id");
  }

might fix this.

Copy link

stale bot commented May 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label May 17, 2024
@stale stale bot closed this May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants