Search in sources :

Example 21 with IMP

use of org.hl7.fhir.r4.model.codesystems.V3ActCode.IMP in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method generateComposition.

private boolean generateComposition(XhtmlNode x, ValueSet vs, boolean header) {
    boolean hasExtensions = false;
    if (header) {
        XhtmlNode h = x.addTag("h2");
        h.addText(vs.getName());
        XhtmlNode p = x.addTag("p");
        smartAddText(p, vs.getDescription());
        if (vs.hasCopyrightElement())
            generateCopyright(x, vs);
    }
    XhtmlNode p = x.addTag("p");
    p.addText("This value set includes codes from the following code systems:");
    XhtmlNode ul = x.addTag("ul");
    XhtmlNode li;
    for (UriType imp : vs.getCompose().getImport()) {
        li = ul.addTag("li");
        li.addText("Import all the codes that are contained in ");
        AddVsRef(imp.getValue(), li);
    }
    for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
        hasExtensions = genInclude(ul, inc, "Include") || hasExtensions;
    }
    for (ConceptSetComponent exc : vs.getCompose().getExclude()) {
        hasExtensions = genInclude(ul, exc, "Exclude") || hasExtensions;
    }
    return hasExtensions;
}
Also used : ConceptSetComponent(org.hl7.fhir.dstu2016may.model.ValueSet.ConceptSetComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) UriType(org.hl7.fhir.dstu2016may.model.UriType)

Example 22 with IMP

use of org.hl7.fhir.r4.model.codesystems.V3ActCode.IMP in project org.hl7.fhir.core by hapifhir.

the class ProfileComparer method unite.

private ValueSet unite(ElementDefinition ed, ProfileComparison outcome, String path, ValueSet lvs, ValueSet rvs) {
    ValueSet vs = new ValueSet();
    if (lvs.hasCompose()) {
        for (UriType imp : lvs.getCompose().getImport()) vs.getCompose().getImport().add(imp);
        for (ConceptSetComponent inc : lvs.getCompose().getInclude()) vs.getCompose().getInclude().add(inc);
        if (lvs.getCompose().hasExclude()) {
            outcome.messages.add(new ValidationMessage(Source.ProfileComparer, IssueType.STRUCTURE, path, "The value sets " + lvs.getUrl() + " has exclude statements, and no union involving it can be correctly determined", IssueSeverity.ERROR));
            status(ed, ProfileUtilities.STATUS_ERROR);
        }
    }
    if (rvs.hasCompose()) {
        for (UriType imp : rvs.getCompose().getImport()) if (!vs.getCompose().hasImport(imp.getValue()))
            vs.getCompose().getImport().add(imp);
        for (ConceptSetComponent inc : rvs.getCompose().getInclude()) if (!mergeIntoExisting(vs.getCompose().getInclude(), inc))
            vs.getCompose().getInclude().add(inc);
        if (rvs.getCompose().hasExclude()) {
            outcome.messages.add(new ValidationMessage(Source.ProfileComparer, IssueType.STRUCTURE, path, "The value sets " + lvs.getUrl() + " has exclude statements, and no union involving it can be correctly determined", IssueSeverity.ERROR));
            status(ed, ProfileUtilities.STATUS_ERROR);
        }
    }
    return vs;
}
Also used : ConceptSetComponent(org.hl7.fhir.dstu2016may.model.ValueSet.ConceptSetComponent) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) ValueSet(org.hl7.fhir.dstu2016may.model.ValueSet) UriType(org.hl7.fhir.dstu2016may.model.UriType)

Example 23 with IMP

use of org.hl7.fhir.r4.model.codesystems.V3ActCode.IMP in project org.hl7.fhir.core by hapifhir.

the class StructureMapUtilities method executeDependency.

private void executeDependency(String indent, TransformContext context, StructureMap map, Variables vin, StructureMapGroupComponent group, StructureMapGroupRuleDependentComponent dependent) throws Exception {
    StructureMap targetMap = null;
    StructureMapGroupComponent target = null;
    for (StructureMapGroupComponent grp : map.getGroup()) {
        if (grp.getName().equals(dependent.getName())) {
            if (targetMap == null) {
                targetMap = map;
                target = grp;
            } else
                throw new FHIRException("Multiple possible matches for rule '" + dependent.getName() + "'");
        }
    }
    for (UriType imp : map.getImport()) {
        StructureMap impMap = library.get(imp.getValue());
        if (impMap == null)
            throw new FHIRException("Unable to find map " + imp.getValue() + " (Known Maps = " + Utilities.listCanonicalUrls(library.keySet()) + ")");
        for (StructureMapGroupComponent grp : impMap.getGroup()) {
            if (grp.getName().equals(dependent.getName())) {
                if (targetMap == null) {
                    targetMap = impMap;
                    target = grp;
                } else
                    throw new FHIRException("Multiple possible matches for rule '" + dependent.getName() + "'");
            }
        }
    }
    if (target == null)
        throw new FHIRException("No matches found for rule '" + dependent.getName() + "'");
    if (target.getInput().size() != dependent.getVariable().size()) {
        throw new FHIRException("Rule '" + dependent.getName() + "' has " + Integer.toString(target.getInput().size()) + " but the invocation has " + Integer.toString(dependent.getVariable().size()) + " variables");
    }
    Variables v = new Variables();
    for (int i = 0; i < target.getInput().size(); i++) {
        StructureMapGroupInputComponent input = target.getInput().get(i);
        StringType var = dependent.getVariable().get(i);
        VariableMode mode = input.getMode() == StructureMapInputMode.SOURCE ? VariableMode.INPUT : VariableMode.OUTPUT;
        Base vv = vin.get(mode, var.getValue());
        if (vv == null)
            throw new FHIRException("Rule '" + dependent.getName() + "' " + mode.toString() + " variable '" + input.getName() + "' has no value");
        v.add(mode, input.getName(), vv);
    }
    executeGroup(indent + "  ", context, targetMap, v, target);
}
Also used : StructureMap(org.hl7.fhir.dstu2016may.model.StructureMap) StructureMapGroupComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupComponent) StringType(org.hl7.fhir.dstu2016may.model.StringType) StructureMapGroupInputComponent(org.hl7.fhir.dstu2016may.model.StructureMap.StructureMapGroupInputComponent) FHIRException(org.hl7.fhir.exceptions.FHIRException) Base(org.hl7.fhir.dstu2016may.model.Base) UriType(org.hl7.fhir.dstu2016may.model.UriType)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)13 ArrayList (java.util.ArrayList)4 UriType (org.hl7.fhir.r4.model.UriType)4 UriType (org.hl7.fhir.dstu2016may.model.UriType)3 StructureMap (org.hl7.fhir.dstu3.model.StructureMap)3 StructureMapGroupComponent (org.hl7.fhir.dstu3.model.StructureMap.StructureMapGroupComponent)3 UriType (org.hl7.fhir.dstu3.model.UriType)3 StructureMap (org.hl7.fhir.r4.model.StructureMap)3 StructureMapGroupComponent (org.hl7.fhir.r4.model.StructureMap.StructureMapGroupComponent)3 StructureMap (org.hl7.fhir.r4b.model.StructureMap)3 StructureMap (org.hl7.fhir.r5.model.StructureMap)3 UriType (org.hl7.fhir.dstu2.model.UriType)2 ConceptSetComponent (org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent)2 ConceptSetComponent (org.hl7.fhir.dstu2016may.model.ValueSet.ConceptSetComponent)2 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)2 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)2 FhirPath (au.csiro.pathling.fhirpath.FhirPath)1 CodingPath (au.csiro.pathling.fhirpath.element.CodingPath)1 ElementDefinition (au.csiro.pathling.fhirpath.element.ElementDefinition)1 NamedFunctionInput (au.csiro.pathling.fhirpath.function.NamedFunctionInput)1