Search in sources :

Example 16 with StructureMapStructureComponent

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

the class StructureMapUtilities method getTargetType.

public StructureDefinition getTargetType(StructureMap map) throws FHIRException {
    boolean found = false;
    StructureDefinition res = null;
    for (StructureMapStructureComponent uses : map.getStructure()) {
        if (uses.getMode() == StructureMapModelMode.TARGET) {
            if (found)
                throw new FHIRException("Multiple targets found in map " + map.getUrl());
            found = true;
            res = worker.fetchResource(StructureDefinition.class, uses.getUrl());
            if (res == null)
                throw new FHIRException("Unable to find " + uses.getUrl() + " referenced from map " + map.getUrl());
        }
    }
    if (res == null)
        throw new FHIRException("No targets found in map " + map.getUrl());
    return res;
}
Also used : FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 17 with StructureMapStructureComponent

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

the class StructureMapUtilities method renderUses.

private void renderUses(StringBuilder b, StructureMap map) {
    for (StructureMapStructureComponent s : map.getStructure()) {
        b.append("uses \"");
        b.append(s.getUrl());
        b.append("\" as ");
        b.append(s.getMode().toCode());
        b.append("\r\n");
        renderDoco(b, s.getDocumentation());
    }
    if (map.hasStructure())
        b.append("\r\n");
}
Also used : StructureMapStructureComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapStructureComponent)

Example 18 with StructureMapStructureComponent

use of org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent 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 : listTransforms()) {
        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 : StructureMapStructureComponent(org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent) ArrayList(java.util.ArrayList)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)7 StructureMapStructureComponent (org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent)5 ArrayList (java.util.ArrayList)4 StructureMapStructureComponent (org.hl7.fhir.dstu3.model.StructureMap.StructureMapStructureComponent)4 IOException (java.io.IOException)3 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)3 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)3 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)3 NotImplementedException (org.apache.commons.lang3.NotImplementedException)2 StructureMapStructureComponent (org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapStructureComponent)2 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)2 ConformanceResourceStatusEnumFactory (org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory)1 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)1 StructureMap (org.hl7.fhir.dstu3.model.StructureMap)1 Base (org.hl7.fhir.r4.model.Base)1 BooleanType (org.hl7.fhir.r4.model.BooleanType)1 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 Coding (org.hl7.fhir.r4.model.Coding)1 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)1 ExpressionNode (org.hl7.fhir.r4.model.ExpressionNode)1