Search in sources :

Example 21 with StructureMapGroupRuleSourceComponent

use of org.hl7.fhir.r4b.model.StructureMap.StructureMapGroupRuleSourceComponent in project org.hl7.fhir.core by hapifhir.

the class StructureMapUtilities method parseSource.

private void parseSource(StructureMapGroupRuleComponent rule, FHIRLexer lexer) throws FHIRException {
    StructureMapGroupRuleSourceComponent source = rule.addSource();
    if (lexer.hasToken("optional"))
        lexer.next();
    else
        source.setRequired(true);
    source.setContext(lexer.take());
    if (lexer.hasToken(".")) {
        lexer.token(".");
        source.setElement(lexer.take());
    }
    if (Utilities.existsInList(lexer.getCurrent(), "first", "last", "only_one"))
        if (lexer.getCurrent().equals("only_one")) {
            source.setListMode(StructureMapListMode.SHARE);
            lexer.take();
        } else
            source.setListMode(StructureMapListMode.fromCode(lexer.take()));
    if (lexer.hasToken("as")) {
        lexer.take();
        source.setVariable(lexer.take());
    }
    if (lexer.hasToken("where")) {
        lexer.take();
        ExpressionNode node = fpe.parse(lexer);
        source.setUserData(MAP_WHERE_EXPRESSION, node);
        source.setCondition(node.toString());
    }
    if (lexer.hasToken("check")) {
        lexer.take();
        ExpressionNode node = fpe.parse(lexer);
        source.setUserData(MAP_WHERE_CHECK, node);
        source.setCheck(node.toString());
    }
}
Also used : ExpressionNode(org.hl7.fhir.dstu2016may.model.ExpressionNode) StructureMapGroupRuleSourceComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleSourceComponent)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)9 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)7 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)4 ArrayList (java.util.ArrayList)3 StringType (org.hl7.fhir.dstu3.model.StringType)3 StringType (org.hl7.fhir.r4.model.StringType)3 ExpressionNode (org.hl7.fhir.dstu2016may.model.ExpressionNode)2 StructureMapGroupRuleSourceComponent (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleSourceComponent)2 ExpressionNode (org.hl7.fhir.dstu3.model.ExpressionNode)2 StructureMapGroupRuleSourceComponent (org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupRuleSourceComponent)2 ExpressionNode (org.hl7.fhir.r4.model.ExpressionNode)2 StructureMapGroupRuleSourceComponent (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupRuleSourceComponent)2 IOException (java.io.IOException)1 Base (org.hl7.fhir.dstu2016may.model.Base)1 StringType (org.hl7.fhir.dstu2016may.model.StringType)1 StructureMapGroupRuleDependentComponent (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleDependentComponent)1 StructureMapGroupRuleTargetComponent (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupRuleTargetComponent)1 FHIRLexerException (org.hl7.fhir.dstu2016may.utils.FHIRLexer.FHIRLexerException)1 Property (org.hl7.fhir.dstu3.elementmodel.Property)1 Base (org.hl7.fhir.dstu3.model.Base)1