Search in sources :

Example 21 with OperationDefinition

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

the class BaseWorkerContext method fetchResourceWithException.

@SuppressWarnings("unchecked")
public <T extends Resource> T fetchResourceWithException(String cls, String uri, CanonicalResource source) throws FHIRException {
    if (uri == null) {
        return null;
    }
    if ("StructureDefinition".equals(cls)) {
        uri = ProfileUtilities.sdNs(uri, getOverrideVersionNs());
    }
    synchronized (lock) {
        String version = null;
        if (uri.contains("|")) {
            version = uri.substring(uri.lastIndexOf("|") + 1);
            uri = uri.substring(0, uri.lastIndexOf("|"));
        }
        if (uri.contains("#")) {
            uri = uri.substring(0, uri.indexOf("#"));
        }
        if (cls == null || "Resource".equals(cls)) {
            if (structures.has(uri)) {
                return (T) structures.get(uri, version);
            }
            if (guides.has(uri)) {
                return (T) guides.get(uri, version);
            }
            if (capstmts.has(uri)) {
                return (T) capstmts.get(uri, version);
            }
            if (measures.has(uri)) {
                return (T) measures.get(uri, version);
            }
            if (libraries.has(uri)) {
                return (T) libraries.get(uri, version);
            }
            if (valueSets.has(uri)) {
                return (T) valueSets.get(uri, version);
            }
            if (codeSystems.has(uri)) {
                return (T) codeSystems.get(uri, version);
            }
            if (operations.has(uri)) {
                return (T) operations.get(uri, version);
            }
            if (searchParameters.has(uri)) {
                return (T) searchParameters.get(uri, version);
            }
            if (plans.has(uri)) {
                return (T) plans.get(uri, version);
            }
            if (maps.has(uri)) {
                return (T) maps.get(uri, version);
            }
            if (transforms.has(uri)) {
                return (T) transforms.get(uri, version);
            }
            if (questionnaires.has(uri)) {
                return (T) questionnaires.get(uri, version);
            }
            for (Map<String, ResourceProxy> rt : allResourcesById.values()) {
                for (ResourceProxy r : rt.values()) {
                    if (uri.equals(r.getUrl())) {
                        return (T) r.getResource();
                    }
                }
            }
        } else if ("ImplementationGuide".equals(cls)) {
            return (T) guides.get(uri, version);
        } else if ("CapabilityStatement".equals(cls)) {
            return (T) capstmts.get(uri, version);
        } else if ("Measure".equals(cls)) {
            return (T) measures.get(uri, version);
        } else if ("Library".equals(cls)) {
            return (T) libraries.get(uri, version);
        } else if ("StructureDefinition".equals(cls)) {
            return (T) structures.get(uri, version);
        } else if ("StructureMap".equals(cls)) {
            return (T) transforms.get(uri, version);
        } else if ("ValueSet".equals(cls)) {
            return (T) valueSets.get(uri, version);
        } else if ("CodeSystem".equals(cls)) {
            return (T) codeSystems.get(uri, version);
        } else if ("ConceptMap".equals(cls)) {
            return (T) maps.get(uri, version);
        } else if ("PlanDefinition".equals(cls)) {
            return (T) plans.get(uri, version);
        } else if ("OperationDefinition".equals(cls)) {
            OperationDefinition od = operations.get(uri, version);
            return (T) od;
        } else if ("Questionnaire.class".equals(cls)) {
            return (T) questionnaires.get(uri, version);
        } else if ("SearchParameter.class".equals(cls)) {
            SearchParameter res = searchParameters.get(uri, version);
            return (T) res;
        }
        if ("CodeSystem".equals(cls) && codeSystems.has(uri)) {
            return (T) codeSystems.get(uri, version);
        }
        if ("ValueSet".equals(cls) && valueSets.has(uri)) {
            return (T) valueSets.get(uri, version);
        }
        if ("Questionnaire".equals(cls)) {
            return (T) questionnaires.get(uri, version);
        }
        if (cls == null) {
            if (uri.matches(Constants.URI_REGEX) && !uri.contains("ValueSet")) {
                return null;
            }
            // it might be a special URL.
            if (Utilities.isAbsoluteUrl(uri) || uri.startsWith("ValueSet/")) {
                // findTxValueSet(uri);
                Resource res = null;
                if (res != null) {
                    return (T) res;
                }
            }
            return null;
        }
        if (supportedCodeSystems.contains(uri)) {
            return null;
        }
        throw new FHIRException(formatMessage(I18nConstants.NOT_DONE_YET_CANT_FETCH_, uri));
    }
}
Also used : CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) Resource(org.hl7.fhir.r5.model.Resource) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) OperationDefinition(org.hl7.fhir.r5.model.OperationDefinition) FHIRException(org.hl7.fhir.exceptions.FHIRException) CanonicalResourceProxy(org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy)

Example 22 with OperationDefinition

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

the class BaseWorkerContext method registerResourceFromPackage.

public void registerResourceFromPackage(CanonicalResourceProxy r, PackageVersion packageInfo) throws FHIRException {
    synchronized (lock) {
        if (r.getId() != null) {
            Map<String, ResourceProxy> map = allResourcesById.get(r.getType());
            if (map == null) {
                map = new HashMap<String, ResourceProxy>();
                allResourcesById.put(r.getType(), map);
            }
            if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
                map.put(r.getId(), new ResourceProxy(r));
            }
        }
        String url = r.getUrl();
        if (!allowLoadingDuplicates && hasResource(r.getType(), url)) {
            // spcial workaround for known problems with existing packages
            if (Utilities.existsInList(url, "http://hl7.org/fhir/SearchParameter/example")) {
                return;
            }
            throw new DefinitionException(formatMessage(I18nConstants.DUPLICATE_RESOURCE_, url));
        }
        switch(r.getType()) {
            case "StructureDefinition":
                if ("1.4.0".equals(version)) {
                    StructureDefinition sd = (StructureDefinition) r.getResource();
                    fixOldSD(sd);
                }
                structures.register(r, packageInfo);
                break;
            case "ValueSet":
                valueSets.register(r, packageInfo);
                break;
            case "CodeSystem":
                codeSystems.register(r, packageInfo);
                break;
            case "ImplementationGuide":
                guides.register(r, packageInfo);
                break;
            case "CapabilityStatement":
                capstmts.register(r, packageInfo);
                break;
            case "Measure":
                measures.register(r, packageInfo);
                break;
            case "Library":
                libraries.register(r, packageInfo);
                break;
            case "SearchParameter":
                searchParameters.register(r, packageInfo);
                break;
            case "PlanDefinition":
                plans.register(r, packageInfo);
                break;
            case "OperationDefinition":
                operations.register(r, packageInfo);
                break;
            case "Questionnaire":
                questionnaires.register(r, packageInfo);
                break;
            case "ConceptMap":
                maps.register(r, packageInfo);
                break;
            case "StructureMap":
                transforms.register(r, packageInfo);
                break;
            case "NamingSystem":
                systems.register(r, packageInfo);
                break;
        }
    }
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) CanonicalResourceProxy(org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy)

Example 23 with OperationDefinition

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

the class BaseWorkerContext method cacheResourceFromPackage.

public void cacheResourceFromPackage(Resource r, PackageVersion packageInfo) throws FHIRException {
    synchronized (lock) {
        if (r.getId() != null) {
            Map<String, ResourceProxy> map = allResourcesById.get(r.fhirType());
            if (map == null) {
                map = new HashMap<String, ResourceProxy>();
                allResourcesById.put(r.fhirType(), map);
            }
            if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
                map.put(r.getId(), new ResourceProxy(r));
            } else {
                logger.logDebugMessage(LogCategory.PROGRESS, "Ignore " + r.fhirType() + "/" + r.getId() + " from package " + packageInfo.toString());
            }
        }
        if (r instanceof CodeSystem || r instanceof NamingSystem) {
            oidCache.clear();
        }
        if (r instanceof CanonicalResource) {
            CanonicalResource m = (CanonicalResource) r;
            String url = m.getUrl();
            if (!allowLoadingDuplicates && hasResource(r.getClass(), url)) {
                // special workaround for known problems with existing packages
                if (Utilities.existsInList(url, "http://hl7.org/fhir/SearchParameter/example")) {
                    return;
                }
                throw new DefinitionException(formatMessage(I18nConstants.DUPLICATE_RESOURCE_, url));
            }
            if (r instanceof StructureDefinition) {
                StructureDefinition sd = (StructureDefinition) m;
                if ("1.4.0".equals(version)) {
                    fixOldSD(sd);
                }
                structures.see(sd, packageInfo);
            } else if (r instanceof ValueSet) {
                valueSets.see((ValueSet) m, packageInfo);
            } else if (r instanceof CodeSystem) {
                CodeSystemUtilities.crossLinkCodeSystem((CodeSystem) r);
                codeSystems.see((CodeSystem) m, packageInfo);
            } else if (r instanceof ImplementationGuide) {
                guides.see((ImplementationGuide) m, packageInfo);
            } else if (r instanceof CapabilityStatement) {
                capstmts.see((CapabilityStatement) m, packageInfo);
            } else if (r instanceof Measure) {
                measures.see((Measure) m, packageInfo);
            } else if (r instanceof Library) {
                libraries.see((Library) m, packageInfo);
            } else if (r instanceof SearchParameter) {
                searchParameters.see((SearchParameter) m, packageInfo);
            } else if (r instanceof PlanDefinition) {
                plans.see((PlanDefinition) m, packageInfo);
            } else if (r instanceof OperationDefinition) {
                operations.see((OperationDefinition) m, packageInfo);
            } else if (r instanceof Questionnaire) {
                questionnaires.see((Questionnaire) m, packageInfo);
            } else if (r instanceof ConceptMap) {
                maps.see((ConceptMap) m, packageInfo);
            } else if (r instanceof StructureMap) {
                transforms.see((StructureMap) m, packageInfo);
            } else if (r instanceof NamingSystem) {
                systems.see((NamingSystem) m, packageInfo);
            }
        }
    }
}
Also used : Questionnaire(org.hl7.fhir.r5.model.Questionnaire) ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) CanonicalResourceProxy(org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy) StructureMap(org.hl7.fhir.r5.model.StructureMap) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) NamingSystem(org.hl7.fhir.r5.model.NamingSystem) CapabilityStatement(org.hl7.fhir.r5.model.CapabilityStatement) Measure(org.hl7.fhir.r5.model.Measure) PlanDefinition(org.hl7.fhir.r5.model.PlanDefinition) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) Library(org.hl7.fhir.r5.model.Library) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) ConceptMap(org.hl7.fhir.r5.model.ConceptMap) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) ValueSet(org.hl7.fhir.r5.model.ValueSet) OperationDefinition(org.hl7.fhir.r5.model.OperationDefinition)

Example 24 with OperationDefinition

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

the class RdfParser method composeOperationDefinitionOperationDefinitionParameterComponent.

protected void composeOperationDefinitionOperationDefinitionParameterComponent(Complex parent, String parentType, String name, OperationDefinition.OperationDefinitionParameterComponent 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.hasNameElement())
        composeCode(t, "OperationDefinition", "name", element.getNameElement(), -1);
    if (element.hasUseElement())
        composeEnum(t, "OperationDefinition", "use", element.getUseElement(), -1);
    if (element.hasMinElement())
        composeInteger(t, "OperationDefinition", "min", element.getMinElement(), -1);
    if (element.hasMaxElement())
        composeString(t, "OperationDefinition", "max", element.getMaxElement(), -1);
    if (element.hasDocumentationElement())
        composeString(t, "OperationDefinition", "documentation", element.getDocumentationElement(), -1);
    if (element.hasTypeElement())
        composeCode(t, "OperationDefinition", "type", element.getTypeElement(), -1);
    for (int i = 0; i < element.getTargetProfile().size(); i++) composeCanonical(t, "OperationDefinition", "targetProfile", element.getTargetProfile().get(i), i);
    if (element.hasSearchTypeElement())
        composeEnum(t, "OperationDefinition", "searchType", element.getSearchTypeElement(), -1);
    if (element.hasBinding())
        composeOperationDefinitionOperationDefinitionParameterBindingComponent(t, "OperationDefinition", "binding", element.getBinding(), -1);
    for (int i = 0; i < element.getReferencedFrom().size(); i++) composeOperationDefinitionOperationDefinitionParameterReferencedFromComponent(t, "OperationDefinition", "referencedFrom", element.getReferencedFrom().get(i), i);
    for (int i = 0; i < element.getPart().size(); i++) composeOperationDefinitionOperationDefinitionParameterComponent(t, "OperationDefinition", "part", element.getPart().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 25 with OperationDefinition

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

the class RdfParser method composeOperationDefinitionOperationDefinitionParameterReferencedFromComponent.

protected void composeOperationDefinitionOperationDefinitionParameterReferencedFromComponent(Complex parent, String parentType, String name, OperationDefinition.OperationDefinitionParameterReferencedFromComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "referencedFrom", name, element, index);
    if (element.hasSourceElement())
        composeString(t, "OperationDefinition", "source", element.getSourceElement(), -1);
    if (element.hasSourceIdElement())
        composeString(t, "OperationDefinition", "sourceId", element.getSourceIdElement(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Aggregations

OperationDefinition (org.hl7.fhir.r5.model.OperationDefinition)10 FHIRException (org.hl7.fhir.exceptions.FHIRException)9 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)8 OperationDefinitionParameterComponent (org.hl7.fhir.r5.model.OperationDefinition.OperationDefinitionParameterComponent)7 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)6 File (java.io.File)5 ArrayList (java.util.ArrayList)5 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)5 XmlParser (org.hl7.fhir.r5.formats.XmlParser)5 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)5 Description (ca.uhn.fhir.model.api.annotation.Description)4 Operation (ca.uhn.fhir.rest.annotation.Operation)4 FileOutputStream (java.io.FileOutputStream)4 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)4 Parameters (org.hl7.fhir.r4.model.Parameters)4 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)4 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)4 CanonicalResource (org.hl7.fhir.r5.model.CanonicalResource)4 Extension (org.hl7.fhir.r5.model.Extension)4 ListResource (org.hl7.fhir.r5.model.ListResource)4