Search in sources :

Example 6 with StructureMap

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

the class Convertor_Factory_40_50Test method testBidirectionalStructureMapConversion.

@Test
public void testBidirectionalStructureMapConversion() {
    StructureMapUtilities smu5 = new StructureMapUtilities(context, mock(org.hl7.fhir.r5.utils.structuremap.ITransformerServices.class));
    org.hl7.fhir.r5.model.StructureMap mapR5 = smu5.parse(CONTENT, "map");
    assertEquals("tgt", mapR5.getGroup().get(0).getRule().get(0).getTarget().get(0).getParameter().get(0).getValueIdType().getValue());
    assertEquals("item.answer.valueString", mapR5.getGroup().get(1).getRule().get(0).getTarget().get(0).getParameter().get(0).getValueStringType().getValue());
    assertEquals("item", mapR5.getGroup().get(0).getRule().get(0).getDependent().get(0).getParameter().get(0).getValueIdType().getValueAsString());
    assertEquals("patient", mapR5.getGroup().get(0).getRule().get(0).getDependent().get(0).getParameter().get(1).getValueIdType().getValueAsString());
    org.hl7.fhir.r4.model.StructureMap mapR4 = (org.hl7.fhir.r4.model.StructureMap) VersionConvertorFactory_40_50.convertResource(mapR5);
    assertEquals("tgt", mapR4.getGroup().get(0).getRule().get(0).getTarget().get(0).getParameter().get(0).getValueIdType().getValue());
    assertEquals("item.answer.valueString", mapR4.getGroup().get(1).getRule().get(0).getTarget().get(0).getParameter().get(0).getValueStringType().getValue());
    assertEquals("item", mapR4.getGroup().get(0).getRule().get(0).getDependent().get(0).getVariable().get(0).getValueAsString());
    assertEquals("patient", mapR4.getGroup().get(0).getRule().get(0).getDependent().get(0).getVariable().get(1).getValueAsString());
    assertEquals("url", mapR4.getGroup().get(0).getRule().get(0).getDependent().get(0).getVariable().get(0).getExtensionByUrl(ToolingExtensions.EXT_ORIGINAL_ELEMENT_TYPE).getValue().fhirType());
    assertEquals("url", mapR4.getGroup().get(0).getRule().get(0).getDependent().get(0).getVariable().get(1).getExtensionByUrl(ToolingExtensions.EXT_ORIGINAL_ELEMENT_TYPE).getValue().fhirType());
    assertEquals("id", ((org.hl7.fhir.r4.model.UrlType) mapR4.getGroup().get(0).getRule().get(0).getDependent().get(0).getVariable().get(0).getExtensionByUrl(ToolingExtensions.EXT_ORIGINAL_ELEMENT_TYPE).getValue()).getValueAsString());
    assertEquals("id", ((org.hl7.fhir.r4.model.UrlType) mapR4.getGroup().get(0).getRule().get(0).getDependent().get(0).getVariable().get(1).getExtensionByUrl(ToolingExtensions.EXT_ORIGINAL_ELEMENT_TYPE).getValue()).getValueAsString());
    StructureMap mapR5Back = (StructureMap) VersionConvertorFactory_40_50.convertResource(mapR4);
    assertEquals("tgt", mapR5Back.getGroup().get(0).getRule().get(0).getTarget().get(0).getParameter().get(0).getValueIdType().getValue());
    assertEquals("item.answer.valueString", mapR5Back.getGroup().get(1).getRule().get(0).getTarget().get(0).getParameter().get(0).getValueStringType().getValue());
    assertEquals("item", mapR5Back.getGroup().get(0).getRule().get(0).getDependent().get(0).getParameter().get(0).getValueIdType().getValueAsString());
    assertEquals("patient", mapR5Back.getGroup().get(0).getRule().get(0).getDependent().get(0).getParameter().get(1).getValueIdType().getValueAsString());
}
Also used : org.hl7.fhir.r5.model(org.hl7.fhir.r5.model) StructureMapUtilities(org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities) Test(org.junit.jupiter.api.Test)

Example 7 with StructureMap

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

the class RdfParser method composeStructureMap.

protected void composeStructureMap(Complex parent, String parentType, String name, StructureMap element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "StructureMap", name, element, index);
    if (element.hasUrlElement())
        composeUri(t, "StructureMap", "url", element.getUrlElement(), -1);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "StructureMap", "identifier", element.getIdentifier().get(i), i);
    if (element.hasVersionElement())
        composeString(t, "StructureMap", "version", element.getVersionElement(), -1);
    if (element.hasNameElement())
        composeString(t, "StructureMap", "name", element.getNameElement(), -1);
    if (element.hasTitleElement())
        composeString(t, "StructureMap", "title", element.getTitleElement(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "StructureMap", "status", element.getStatusElement(), -1);
    if (element.hasExperimentalElement())
        composeBoolean(t, "StructureMap", "experimental", element.getExperimentalElement(), -1);
    if (element.hasDateElement())
        composeDateTime(t, "StructureMap", "date", element.getDateElement(), -1);
    if (element.hasPublisherElement())
        composeString(t, "StructureMap", "publisher", element.getPublisherElement(), -1);
    for (int i = 0; i < element.getContact().size(); i++) composeContactDetail(t, "StructureMap", "contact", element.getContact().get(i), i);
    if (element.hasDescriptionElement())
        composeMarkdown(t, "StructureMap", "description", element.getDescriptionElement(), -1);
    for (int i = 0; i < element.getUseContext().size(); i++) composeUsageContext(t, "StructureMap", "useContext", element.getUseContext().get(i), i);
    for (int i = 0; i < element.getJurisdiction().size(); i++) composeCodeableConcept(t, "StructureMap", "jurisdiction", element.getJurisdiction().get(i), i);
    if (element.hasPurposeElement())
        composeMarkdown(t, "StructureMap", "purpose", element.getPurposeElement(), -1);
    if (element.hasCopyrightElement())
        composeMarkdown(t, "StructureMap", "copyright", element.getCopyrightElement(), -1);
    for (int i = 0; i < element.getStructure().size(); i++) composeStructureMapStructureMapStructureComponent(t, "StructureMap", "structure", element.getStructure().get(i), i);
    for (int i = 0; i < element.getImport().size(); i++) composeUri(t, "StructureMap", "import", element.getImport().get(i), i);
    for (int i = 0; i < element.getGroup().size(); i++) composeStructureMapStructureMapGroupComponent(t, "StructureMap", "group", element.getGroup().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 8 with StructureMap

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

the class RdfParser method composeStructureMapStructureMapGroupRuleTargetParameterComponent.

protected void composeStructureMapStructureMapGroupRuleTargetParameterComponent(Complex parent, String parentType, String name, StructureMap.StructureMapGroupRuleTargetParameterComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "parameter", name, element, index);
    if (element.hasValue())
        composeType(t, "StructureMap", "value", element.getValue(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 9 with StructureMap

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

the class SimpleWorkerContext method findTransformsforSource.

public List<StructureMap> findTransformsforSource(String url) {
    List<StructureMap> res = new ArrayList<StructureMap>();
    for (StructureMap map : transforms.values()) {
        boolean match = false;
        boolean ok = true;
        for (StructureMapStructureComponent t : map.getStructure()) {
            if (t.getMode() == StructureMapModelMode.SOURCE) {
                match = match || t.getUrl().equals(url);
                ok = ok && t.getUrl().equals(url);
            }
        }
        if (match && ok)
            res.add(map);
    }
    return res;
}
Also used : StructureMap(org.hl7.fhir.dstu3.model.StructureMap) StructureMapStructureComponent(org.hl7.fhir.dstu3.model.StructureMap.StructureMapStructureComponent) ArrayList(java.util.ArrayList)

Example 10 with StructureMap

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

the class StructureMapTests method testParse.

private void testParse(String path) throws FileNotFoundException, IOException, FHIRException {
    if (TestingUtilities.context == null)
        TestingUtilities.context = SimpleWorkerContext.fromPack("C:\\work\\org.hl7.fhir.2016May\\build\\publish\\validation-min.xml.zip");
    StructureMapUtilities scm = new StructureMapUtilities(TestingUtilities.context, null, null);
    StructureMap map = scm.parse(TextFile.fileToString(Utilities.path("C:\\work\\org.hl7.fhir.2016May\\build", path)));
    TextFile.stringToFile(scm.render(map), Utilities.path("C:\\work\\org.hl7.fhir.2016May\\build", path + ".out"));
}
Also used : StructureMap(org.hl7.fhir.dstu2016may.model.StructureMap) StructureMapUtilities(org.hl7.fhir.dstu2016may.utils.StructureMapUtilities)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)69 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)23 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)17 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)16 StructureMap (org.hl7.fhir.r4b.model.StructureMap)13 StructureMap (org.hl7.fhir.r5.model.StructureMap)13 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)11 StructureMap (org.hl7.fhir.r4.model.StructureMap)11 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)11 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)10 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)9 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)9 StructureMap (org.hl7.fhir.dstu3.model.StructureMap)8 File (java.io.File)7 UriType (org.hl7.fhir.r4.model.UriType)7 Test (org.junit.jupiter.api.Test)7 Base (org.hl7.fhir.dstu3.model.Base)6 TextFile (org.hl7.fhir.utilities.TextFile)6 FileOutputStream (java.io.FileOutputStream)5