Search in sources :

Example 16 with IMP

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

the class ValueSetExpanderSimple method includeCodes.

private void includeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, boolean heirarchical, List<Extension> extensions) throws ETooCostly, FileNotFoundException, IOException, FHIRException {
    inc.checkNoModifiers("Compose.include", "expanding");
    List<ValueSet> imports = new ArrayList<ValueSet>();
    for (UriType imp : inc.getValueSet()) {
        imports.add(importValueSet(imp.getValue(), exp, expParams));
    }
    if (!inc.hasSystem()) {
        if (// though this is not supposed to be the case
        imports.isEmpty())
            return;
        ValueSet base = imports.get(0);
        imports.remove(0);
        base.checkNoModifiers("Imported ValueSet", "expanding");
        copyImportContains(base.getExpansion().getContains(), null, expParams, imports);
    } else {
        CodeSystem cs = context.fetchCodeSystem(inc.getSystem());
        if (isServerSide(inc.getSystem()) || (cs == null || (cs.getContent() != CodeSystemContentMode.COMPLETE && cs.getContent() != CodeSystemContentMode.FRAGMENT))) {
            doServerIncludeCodes(inc, heirarchical, exp, imports, expParams, extensions);
        } else {
            doInternalIncludeCodes(inc, exp, expParams, imports, cs);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ValueSet(org.hl7.fhir.r4b.model.ValueSet) CodeSystem(org.hl7.fhir.r4b.model.CodeSystem) UriType(org.hl7.fhir.r4b.model.UriType)

Example 17 with IMP

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

the class StructureMapUtilities method determineTypeFromSourceType.

private String determineTypeFromSourceType(StructureMap map, StructureMapGroupComponent source, Base base, String[] types) throws FHIRException {
    String type = base.fhirType();
    String kn = "type^" + type;
    if (source.hasUserData(kn))
        return source.getUserString(kn);
    ResolvedGroup res = new ResolvedGroup();
    res.targetMap = null;
    res.target = null;
    for (StructureMapGroupComponent grp : map.getGroup()) {
        if (matchesByType(map, grp, type)) {
            if (res.targetMap == null) {
                res.targetMap = map;
                res.target = grp;
            } else
                throw new FHIRException("Multiple possible matches looking for default rule for '" + type + "'");
        }
    }
    if (res.targetMap != null) {
        String result = getActualType(res.targetMap, res.target.getInput().get(1).getType());
        source.setUserData(kn, result);
        return result;
    }
    for (UriType imp : map.getImport()) {
        List<StructureMap> impMapList = findMatchingMaps(imp.getValue());
        if (impMapList.size() == 0)
            throw new FHIRException("Unable to find map(s) for " + imp.getValue());
        for (StructureMap impMap : impMapList) {
            if (!impMap.getUrl().equals(map.getUrl())) {
                for (StructureMapGroupComponent grp : impMap.getGroup()) {
                    if (matchesByType(impMap, grp, type)) {
                        if (res.targetMap == null) {
                            res.targetMap = impMap;
                            res.target = grp;
                        } else
                            throw new FHIRException("Multiple possible matches for default rule for '" + type + "' in " + res.targetMap.getUrl() + " (" + res.target.getName() + ") and " + impMap.getUrl() + " (" + grp.getName() + ")");
                    }
                }
            }
        }
    }
    if (res.target == null)
        throw new FHIRException("No matches found for default rule for '" + type + "' from " + map.getUrl());
    // should be .getType, but R2...
    String result = getActualType(res.targetMap, res.target.getInput().get(1).getType());
    source.setUserData(kn, result);
    return result;
}
Also used : StructureMapGroupComponent(org.hl7.fhir.r4.model.StructureMap.StructureMapGroupComponent) StructureMap(org.hl7.fhir.r4.model.StructureMap) FHIRException(org.hl7.fhir.exceptions.FHIRException) UriType(org.hl7.fhir.r4.model.UriType)

Example 18 with IMP

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

the class StructureMapUtilities method resolveGroupReference.

private ResolvedGroup resolveGroupReference(StructureMap map, StructureMapGroupComponent source, String name) throws FHIRException {
    String kn = "ref^" + name;
    if (source.hasUserData(kn))
        return (ResolvedGroup) source.getUserData(kn);
    ResolvedGroup res = new ResolvedGroup();
    res.targetMap = null;
    res.target = null;
    for (StructureMapGroupComponent grp : map.getGroup()) {
        if (grp.getName().equals(name)) {
            if (res.targetMap == null) {
                res.targetMap = map;
                res.target = grp;
            } else
                throw new FHIRException("Multiple possible matches for rule '" + name + "'");
        }
    }
    if (res.targetMap != null) {
        source.setUserData(kn, res);
        return res;
    }
    for (UriType imp : map.getImport()) {
        List<StructureMap> impMapList = findMatchingMaps(imp.getValue());
        if (impMapList.size() == 0)
            throw new FHIRException("Unable to find map(s) for " + imp.getValue());
        for (StructureMap impMap : impMapList) {
            if (!impMap.getUrl().equals(map.getUrl())) {
                for (StructureMapGroupComponent grp : impMap.getGroup()) {
                    if (grp.getName().equals(name)) {
                        if (res.targetMap == null) {
                            res.targetMap = impMap;
                            res.target = grp;
                        } else
                            throw new FHIRException("Multiple possible matches for rule group '" + name + "' in " + res.targetMap.getUrl() + "#" + res.target.getName() + " and " + impMap.getUrl() + "#" + grp.getName());
                    }
                }
            }
        }
    }
    if (res.target == null)
        throw new FHIRException("No matches found for rule '" + name + "'. Reference found in " + map.getUrl());
    source.setUserData(kn, res);
    return res;
}
Also used : StructureMap(org.hl7.fhir.r4b.model.StructureMap) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 19 with IMP

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

the class StructureMapUtilities method determineTypeFromSourceType.

private String determineTypeFromSourceType(StructureMap map, StructureMapGroupComponent source, Base base, String[] types) throws FHIRException {
    String type = base.fhirType();
    String kn = "type^" + type;
    if (source.hasUserData(kn))
        return source.getUserString(kn);
    ResolvedGroup res = new ResolvedGroup();
    res.targetMap = null;
    res.target = null;
    for (StructureMapGroupComponent grp : map.getGroup()) {
        if (matchesByType(map, grp, type)) {
            if (res.targetMap == null) {
                res.targetMap = map;
                res.target = grp;
            } else
                throw new FHIRException("Multiple possible matches looking for default rule for '" + type + "'");
        }
    }
    if (res.targetMap != null) {
        String result = getActualType(res.targetMap, res.target.getInput().get(1).getType());
        source.setUserData(kn, result);
        return result;
    }
    for (UriType imp : map.getImport()) {
        List<StructureMap> impMapList = findMatchingMaps(imp.getValue());
        if (impMapList.size() == 0)
            throw new FHIRException("Unable to find map(s) for " + imp.getValue());
        for (StructureMap impMap : impMapList) {
            if (!impMap.getUrl().equals(map.getUrl())) {
                for (StructureMapGroupComponent grp : impMap.getGroup()) {
                    if (matchesByType(impMap, grp, type)) {
                        if (res.targetMap == null) {
                            res.targetMap = impMap;
                            res.target = grp;
                        } else
                            throw new FHIRException("Multiple possible matches for default rule for '" + type + "' in " + res.targetMap.getUrl() + " (" + res.target.getName() + ") and " + impMap.getUrl() + " (" + grp.getName() + ")");
                    }
                }
            }
        }
    }
    if (res.target == null)
        throw new FHIRException("No matches found for default rule for '" + type + "' from " + map.getUrl());
    // should be .getType, but R2...
    String result = getActualType(res.targetMap, res.target.getInput().get(1).getType());
    source.setUserData(kn, result);
    return result;
}
Also used : StructureMap(org.hl7.fhir.r4b.model.StructureMap) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 20 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.hasCodeSystem())
        vs.getCompose().addInclude().setSystem(lvs.getCodeSystem().getSystem());
    if (rvs.hasCodeSystem())
        vs.getCompose().addInclude().setSystem(rvs.getCodeSystem().getSystem());
    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.dstu2.model.ValueSet.ConceptSetComponent) ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) ValueSet(org.hl7.fhir.dstu2.model.ValueSet) UriType(org.hl7.fhir.dstu2.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