Search in sources :

Example 56 with SearchParameter

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

the class BaseWorkerContext method cacheResource.

public void cacheResource(Resource r) throws FHIRException {
    synchronized (lock) {
        Map<String, Resource> map = allResourcesById.get(r.fhirType());
        if (map == null) {
            map = new HashMap<String, Resource>();
            allResourcesById.put(r.fhirType(), map);
        }
        map.put(r.getId(), r);
        if (r instanceof MetadataResource) {
            MetadataResource m = (MetadataResource) r;
            String url = m.getUrl();
            if (!allowLoadingDuplicates && hasResource(r.getClass(), url))
                throw new DefinitionException("Duplicate Resource " + url);
            if (r instanceof StructureDefinition)
                seeMetadataResource((StructureDefinition) m, structures, false);
            else if (r instanceof ValueSet)
                seeMetadataResource((ValueSet) m, valueSets, false);
            else if (r instanceof CodeSystem)
                seeMetadataResource((CodeSystem) m, codeSystems, false);
            else if (r instanceof ImplementationGuide)
                seeMetadataResource((ImplementationGuide) m, guides, false);
            else if (r instanceof CapabilityStatement)
                seeMetadataResource((CapabilityStatement) m, capstmts, false);
            else if (r instanceof SearchParameter)
                seeMetadataResource((SearchParameter) m, searchParameters, false);
            else if (r instanceof PlanDefinition)
                seeMetadataResource((PlanDefinition) m, plans, false);
            else if (r instanceof OperationDefinition)
                seeMetadataResource((OperationDefinition) m, operations, false);
            else if (r instanceof Questionnaire)
                seeMetadataResource((Questionnaire) m, questionnaires, true);
            else if (r instanceof ConceptMap)
                seeMetadataResource((ConceptMap) m, maps, false);
            else if (r instanceof StructureMap)
                seeMetadataResource((StructureMap) m, transforms, false);
            else if (r instanceof NamingSystem)
                systems.add((NamingSystem) r);
        }
    }
}
Also used : DefinitionException(org.hl7.fhir.exceptions.DefinitionException)

Example 57 with SearchParameter

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

the class RdfParser method composeSearchParameterSearchParameterComponentComponent.

protected void composeSearchParameterSearchParameterComponentComponent(Complex parent, String parentType, String name, SearchParameter.SearchParameterComponentComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "component", name, element, index);
    if (element.hasDefinition())
        composeReference(t, "SearchParameter", "definition", element.getDefinition(), -1);
    if (element.hasExpressionElement())
        composeString(t, "SearchParameter", "expression", element.getExpressionElement(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 58 with SearchParameter

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

the class RdfParser method composeSearchParameter.

protected void composeSearchParameter(Complex parent, String parentType, String name, SearchParameter element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "SearchParameter", name, element, index);
    if (element.hasUrlElement())
        composeUri(t, "SearchParameter", "url", element.getUrlElement(), -1);
    if (element.hasVersionElement())
        composeString(t, "SearchParameter", "version", element.getVersionElement(), -1);
    if (element.hasNameElement())
        composeString(t, "SearchParameter", "name", element.getNameElement(), -1);
    if (element.hasDerivedFromElement())
        composeCanonical(t, "SearchParameter", "derivedFrom", element.getDerivedFromElement(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "SearchParameter", "status", element.getStatusElement(), -1);
    if (element.hasExperimentalElement())
        composeBoolean(t, "SearchParameter", "experimental", element.getExperimentalElement(), -1);
    if (element.hasDateElement())
        composeDateTime(t, "SearchParameter", "date", element.getDateElement(), -1);
    if (element.hasPublisherElement())
        composeString(t, "SearchParameter", "publisher", element.getPublisherElement(), -1);
    for (int i = 0; i < element.getContact().size(); i++) composeContactDetail(t, "SearchParameter", "contact", element.getContact().get(i), i);
    if (element.hasDescriptionElement())
        composeMarkdown(t, "SearchParameter", "description", element.getDescriptionElement(), -1);
    for (int i = 0; i < element.getUseContext().size(); i++) composeUsageContext(t, "SearchParameter", "useContext", element.getUseContext().get(i), i);
    for (int i = 0; i < element.getJurisdiction().size(); i++) composeCodeableConcept(t, "SearchParameter", "jurisdiction", element.getJurisdiction().get(i), i);
    if (element.hasPurposeElement())
        composeMarkdown(t, "SearchParameter", "purpose", element.getPurposeElement(), -1);
    if (element.hasCodeElement())
        composeCode(t, "SearchParameter", "code", element.getCodeElement(), -1);
    for (int i = 0; i < element.getBase().size(); i++) composeCode(t, "SearchParameter", "base", element.getBase().get(i), i);
    if (element.hasTypeElement())
        composeEnum(t, "SearchParameter", "type", element.getTypeElement(), -1);
    if (element.hasExpressionElement())
        composeString(t, "SearchParameter", "expression", element.getExpressionElement(), -1);
    if (element.hasXpathElement())
        composeString(t, "SearchParameter", "xpath", element.getXpathElement(), -1);
    if (element.hasXpathUsageElement())
        composeEnum(t, "SearchParameter", "xpathUsage", element.getXpathUsageElement(), -1);
    for (int i = 0; i < element.getTarget().size(); i++) composeCode(t, "SearchParameter", "target", element.getTarget().get(i), i);
    if (element.hasMultipleOrElement())
        composeBoolean(t, "SearchParameter", "multipleOr", element.getMultipleOrElement(), -1);
    if (element.hasMultipleAndElement())
        composeBoolean(t, "SearchParameter", "multipleAnd", element.getMultipleAndElement(), -1);
    for (int i = 0; i < element.getComparator().size(); i++) composeEnum(t, "SearchParameter", "comparator", element.getComparator().get(i), i);
    for (int i = 0; i < element.getModifier().size(); i++) composeEnum(t, "SearchParameter", "modifier", element.getModifier().get(i), i);
    for (int i = 0; i < element.getChain().size(); i++) composeString(t, "SearchParameter", "chain", element.getChain().get(i), i);
    for (int i = 0; i < element.getComponent().size(); i++) composeSearchParameterSearchParameterComponentComponent(t, "SearchParameter", "component", element.getComponent().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 59 with SearchParameter

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

the class BaseWorkerContext method cacheResourceFromPackage.

public void cacheResourceFromPackage(Resource r, PackageVersion packageInfo) throws FHIRException {
    synchronized (lock) {
        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 {
            System.out.println("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)) {
                // 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));
            }
            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.r4b.model.Questionnaire) ImplementationGuide(org.hl7.fhir.r4b.model.ImplementationGuide) CodeSystem(org.hl7.fhir.r4b.model.CodeSystem) CanonicalResourceProxy(org.hl7.fhir.r4b.context.CanonicalResourceManager.CanonicalResourceProxy) ResourceProxy(org.hl7.fhir.r4b.context.BaseWorkerContext.ResourceProxy) StructureMap(org.hl7.fhir.r4b.model.StructureMap) StructureDefinition(org.hl7.fhir.r4b.model.StructureDefinition) NamingSystem(org.hl7.fhir.r4b.model.NamingSystem) CapabilityStatement(org.hl7.fhir.r4b.model.CapabilityStatement) Measure(org.hl7.fhir.r4b.model.Measure) PlanDefinition(org.hl7.fhir.r4b.model.PlanDefinition) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) Library(org.hl7.fhir.r4b.model.Library) SearchParameter(org.hl7.fhir.r4b.model.SearchParameter) ConceptMap(org.hl7.fhir.r4b.model.ConceptMap) CanonicalResource(org.hl7.fhir.r4b.model.CanonicalResource) ValueSet(org.hl7.fhir.r4b.model.ValueSet) OperationDefinition(org.hl7.fhir.r4b.model.OperationDefinition)

Example 60 with SearchParameter

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

the class BaseWorkerContext method registerResourceFromPackage.

public void registerResourceFromPackage(CanonicalResourceProxy r, PackageVersion packageInfo) throws FHIRException {
    synchronized (lock) {
        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.r4b.model.StructureDefinition) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) CanonicalResourceProxy(org.hl7.fhir.r4b.context.CanonicalResourceManager.CanonicalResourceProxy) ResourceProxy(org.hl7.fhir.r4b.context.BaseWorkerContext.ResourceProxy)

Aggregations

SearchParameter (org.hl7.fhir.r5.model.SearchParameter)32 FHIRException (org.hl7.fhir.exceptions.FHIRException)13 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)13 ArrayList (java.util.ArrayList)12 File (java.io.File)9 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)9 SearchParameter (org.hl7.fhir.r4b.model.SearchParameter)9 CodeType (org.hl7.fhir.r5.model.CodeType)9 HashSet (java.util.HashSet)8 FileOutputStream (java.io.FileOutputStream)7 XmlParser (org.hl7.fhir.r5.formats.XmlParser)7 FileNotFoundException (java.io.FileNotFoundException)6 IOException (java.io.IOException)6 SearchParameterDefn (org.hl7.fhir.definitions.model.SearchParameterDefn)6 CanonicalResource (org.hl7.fhir.r5.model.CanonicalResource)6 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)6 ImplementationGuide (org.hl7.fhir.r5.model.ImplementationGuide)6 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)6 ConstraintStructure (org.hl7.fhir.definitions.model.ConstraintStructure)5 Example (org.hl7.fhir.definitions.model.Example)5