Search in sources :

Example 51 with FHIRVersion

use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeStructureDefinition.

protected void composeStructureDefinition(Complex parent, String parentType, String name, StructureDefinition element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "StructureDefinition", name, element, index);
    if (element.hasUrlElement())
        composeUri(t, "StructureDefinition", "url", element.getUrlElement(), -1);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "StructureDefinition", "identifier", element.getIdentifier().get(i), i);
    if (element.hasVersionElement())
        composeString(t, "StructureDefinition", "version", element.getVersionElement(), -1);
    if (element.hasNameElement())
        composeString(t, "StructureDefinition", "name", element.getNameElement(), -1);
    if (element.hasDisplayElement())
        composeString(t, "StructureDefinition", "display", element.getDisplayElement(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "StructureDefinition", "status", element.getStatusElement(), -1);
    if (element.hasExperimentalElement())
        composeBoolean(t, "StructureDefinition", "experimental", element.getExperimentalElement(), -1);
    if (element.hasPublisherElement())
        composeString(t, "StructureDefinition", "publisher", element.getPublisherElement(), -1);
    for (int i = 0; i < element.getContact().size(); i++) composeStructureDefinitionStructureDefinitionContactComponent(t, "StructureDefinition", "contact", element.getContact().get(i), i);
    if (element.hasDateElement())
        composeDateTime(t, "StructureDefinition", "date", element.getDateElement(), -1);
    if (element.hasDescriptionElement())
        composeString(t, "StructureDefinition", "description", element.getDescriptionElement(), -1);
    for (int i = 0; i < element.getUseContext().size(); i++) composeCodeableConcept(t, "StructureDefinition", "useContext", element.getUseContext().get(i), i);
    if (element.hasRequirementsElement())
        composeString(t, "StructureDefinition", "requirements", element.getRequirementsElement(), -1);
    if (element.hasCopyrightElement())
        composeString(t, "StructureDefinition", "copyright", element.getCopyrightElement(), -1);
    for (int i = 0; i < element.getCode().size(); i++) composeCoding(t, "StructureDefinition", "code", element.getCode().get(i), i);
    if (element.hasFhirVersionElement())
        composeId(t, "StructureDefinition", "fhirVersion", element.getFhirVersionElement(), -1);
    for (int i = 0; i < element.getMapping().size(); i++) composeStructureDefinitionStructureDefinitionMappingComponent(t, "StructureDefinition", "mapping", element.getMapping().get(i), i);
    if (element.hasKindElement())
        composeEnum(t, "StructureDefinition", "kind", element.getKindElement(), -1);
    if (element.hasAbstractElement())
        composeBoolean(t, "StructureDefinition", "abstract", element.getAbstractElement(), -1);
    if (element.hasContextTypeElement())
        composeEnum(t, "StructureDefinition", "contextType", element.getContextTypeElement(), -1);
    for (int i = 0; i < element.getContext().size(); i++) composeString(t, "StructureDefinition", "context", element.getContext().get(i), i);
    if (element.hasBaseTypeElement())
        composeCode(t, "StructureDefinition", "baseType", element.getBaseTypeElement(), -1);
    if (element.hasBaseDefinitionElement())
        composeUri(t, "StructureDefinition", "baseDefinition", element.getBaseDefinitionElement(), -1);
    if (element.hasDerivationElement())
        composeEnum(t, "StructureDefinition", "derivation", element.getDerivationElement(), -1);
    if (element.hasSnapshot())
        composeStructureDefinitionStructureDefinitionSnapshotComponent(t, "StructureDefinition", "snapshot", element.getSnapshot(), -1);
    if (element.hasDifferential())
        composeStructureDefinitionStructureDefinitionDifferentialComponent(t, "StructureDefinition", "differential", element.getDifferential(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 52 with FHIRVersion

use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeImplementationGuide.

protected void composeImplementationGuide(Complex parent, String parentType, String name, ImplementationGuide element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "ImplementationGuide", name, element, index);
    if (element.hasUrlElement())
        composeUri(t, "ImplementationGuide", "url", element.getUrlElement(), -1);
    if (element.hasVersionElement())
        composeString(t, "ImplementationGuide", "version", element.getVersionElement(), -1);
    if (element.hasNameElement())
        composeString(t, "ImplementationGuide", "name", element.getNameElement(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "ImplementationGuide", "status", element.getStatusElement(), -1);
    if (element.hasExperimentalElement())
        composeBoolean(t, "ImplementationGuide", "experimental", element.getExperimentalElement(), -1);
    if (element.hasPublisherElement())
        composeString(t, "ImplementationGuide", "publisher", element.getPublisherElement(), -1);
    for (int i = 0; i < element.getContact().size(); i++) composeImplementationGuideImplementationGuideContactComponent(t, "ImplementationGuide", "contact", element.getContact().get(i), i);
    if (element.hasDateElement())
        composeDateTime(t, "ImplementationGuide", "date", element.getDateElement(), -1);
    if (element.hasDescriptionElement())
        composeString(t, "ImplementationGuide", "description", element.getDescriptionElement(), -1);
    for (int i = 0; i < element.getUseContext().size(); i++) composeCodeableConcept(t, "ImplementationGuide", "useContext", element.getUseContext().get(i), i);
    if (element.hasCopyrightElement())
        composeString(t, "ImplementationGuide", "copyright", element.getCopyrightElement(), -1);
    if (element.hasFhirVersionElement())
        composeId(t, "ImplementationGuide", "fhirVersion", element.getFhirVersionElement(), -1);
    for (int i = 0; i < element.getDependency().size(); i++) composeImplementationGuideImplementationGuideDependencyComponent(t, "ImplementationGuide", "dependency", element.getDependency().get(i), i);
    for (int i = 0; i < element.getPackage().size(); i++) composeImplementationGuideImplementationGuidePackageComponent(t, "ImplementationGuide", "package", element.getPackage().get(i), i);
    for (int i = 0; i < element.getGlobal().size(); i++) composeImplementationGuideImplementationGuideGlobalComponent(t, "ImplementationGuide", "global", element.getGlobal().get(i), i);
    for (int i = 0; i < element.getBinary().size(); i++) composeUri(t, "ImplementationGuide", "binary", element.getBinary().get(i), i);
    if (element.hasPage())
        composeImplementationGuideImplementationGuidePageComponent(t, "ImplementationGuide", "page", element.getPage(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 53 with FHIRVersion

use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.

the class PackageClient method search.

public List<PackageInfo> search(String name, String canonical, String fhirVersion, boolean preRelease) throws IOException {
    CommaSeparatedStringBuilder params = new CommaSeparatedStringBuilder("&");
    if (!Utilities.noString(name)) {
        params.append("name=" + name);
    }
    if (!Utilities.noString(canonical)) {
        params.append("canonical=" + canonical);
    }
    if (!Utilities.noString(fhirVersion)) {
        params.append("fhirversion=" + fhirVersion);
    }
    if (preRelease) {
        params.append("prerelease=" + preRelease);
    }
    List<PackageInfo> res = new ArrayList<>();
    try {
        JsonArray json = fetchJsonArray(Utilities.pathURL(address, "catalog?") + params.toString());
        for (JsonElement e : json) {
            JsonObject obj = (JsonObject) e;
            res.add(new PackageInfo(JSONUtil.str(obj, "Name", "name"), JSONUtil.str(obj, "Version", "version"), JSONUtil.str(obj, "FhirVersion", "fhirVersion"), JSONUtil.str(obj, "Description", "description"), JSONUtil.str(obj, "url"), JSONUtil.str(obj, "canonical"), address));
        }
    } catch (IOException e1) {
    }
    return res;
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) ArrayList(java.util.ArrayList) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) JsonObject(com.google.gson.JsonObject) IOException(java.io.IOException)

Example 54 with FHIRVersion

use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.

the class IgLoader method loadResourceByVersion.

public Resource loadResourceByVersion(String fhirVersion, byte[] content, String fn) throws IOException, FHIRException {
    Resource r;
    if (fhirVersion.startsWith("3.0")) {
        org.hl7.fhir.dstu3.model.Resource res;
        if (fn.endsWith(".xml") && !fn.endsWith("template.xml"))
            res = new org.hl7.fhir.dstu3.formats.XmlParser().parse(new ByteArrayInputStream(content));
        else if (fn.endsWith(".json") && !fn.endsWith("template.json"))
            res = new org.hl7.fhir.dstu3.formats.JsonParser().parse(new ByteArrayInputStream(content));
        else if (fn.endsWith(".txt") || fn.endsWith(".map"))
            res = new org.hl7.fhir.dstu3.utils.StructureMapUtilities(null).parse(new String(content));
        else
            throw new FHIRException("Unsupported format for " + fn);
        r = VersionConvertorFactory_30_50.convertResource(res);
    } else if (fhirVersion.startsWith("4.0")) {
        org.hl7.fhir.r4.model.Resource res;
        if (fn.endsWith(".xml") && !fn.endsWith("template.xml"))
            res = new org.hl7.fhir.r4.formats.XmlParser().parse(new ByteArrayInputStream(content));
        else if (fn.endsWith(".json") && !fn.endsWith("template.json"))
            res = new org.hl7.fhir.r4.formats.JsonParser().parse(new ByteArrayInputStream(content));
        else if (fn.endsWith(".txt") || fn.endsWith(".map"))
            res = new org.hl7.fhir.r4.utils.StructureMapUtilities(null).parse(new String(content), fn);
        else
            throw new FHIRException("Unsupported format for " + fn);
        r = VersionConvertorFactory_40_50.convertResource(res);
    } else if (fhirVersion.startsWith("1.4")) {
        org.hl7.fhir.dstu2016may.model.Resource res;
        if (fn.endsWith(".xml") && !fn.endsWith("template.xml"))
            res = new org.hl7.fhir.dstu2016may.formats.XmlParser().parse(new ByteArrayInputStream(content));
        else if (fn.endsWith(".json") && !fn.endsWith("template.json"))
            res = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(new ByteArrayInputStream(content));
        else
            throw new FHIRException("Unsupported format for " + fn);
        r = VersionConvertorFactory_14_50.convertResource(res);
    } else if (fhirVersion.startsWith("1.0")) {
        org.hl7.fhir.dstu2.model.Resource res;
        if (fn.endsWith(".xml") && !fn.endsWith("template.xml"))
            res = new org.hl7.fhir.dstu2.formats.JsonParser().parse(new ByteArrayInputStream(content));
        else if (fn.endsWith(".json") && !fn.endsWith("template.json"))
            res = new org.hl7.fhir.dstu2.formats.JsonParser().parse(new ByteArrayInputStream(content));
        else
            throw new FHIRException("Unsupported format for " + fn);
        r = VersionConvertorFactory_10_50.convertResource(res, new org.hl7.fhir.convertors.misc.IGR2ConvertorAdvisor5());
    } else if (fhirVersion.equals(Constants.VERSION) || "current".equals(fhirVersion)) {
        if (fn.endsWith(".xml") && !fn.endsWith("template.xml"))
            r = new XmlParser().parse(new ByteArrayInputStream(content));
        else if (fn.endsWith(".json") && !fn.endsWith("template.json"))
            r = new JsonParser().parse(new ByteArrayInputStream(content));
        else if (fn.endsWith(".txt"))
            r = new StructureMapUtilities(getContext(), null, null).parse(TextFile.bytesToString(content), fn);
        else if (fn.endsWith(".map"))
            r = new StructureMapUtilities(null).parse(new String(content), fn);
        else
            throw new FHIRException("Unsupported format for " + fn);
    } else
        throw new FHIRException("Unsupported version " + fhirVersion);
    return r;
}
Also used : JsonParser(org.hl7.fhir.r5.formats.JsonParser) XmlParser(org.hl7.fhir.r5.formats.XmlParser) Resource(org.hl7.fhir.r5.model.Resource) FHIRException(org.hl7.fhir.exceptions.FHIRException) StructureMapUtilities(org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities)

Example 55 with FHIRVersion

use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeImplementationGuide.

protected void composeImplementationGuide(Complex parent, String parentType, String name, ImplementationGuide element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "ImplementationGuide", name, element, index);
    if (element.hasUrlElement())
        composeUri(t, "ImplementationGuide", "url", element.getUrlElement(), -1);
    if (element.hasVersionElement())
        composeString(t, "ImplementationGuide", "version", element.getVersionElement(), -1);
    if (element.hasNameElement())
        composeString(t, "ImplementationGuide", "name", element.getNameElement(), -1);
    if (element.hasTitleElement())
        composeString(t, "ImplementationGuide", "title", element.getTitleElement(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "ImplementationGuide", "status", element.getStatusElement(), -1);
    if (element.hasExperimentalElement())
        composeBoolean(t, "ImplementationGuide", "experimental", element.getExperimentalElement(), -1);
    if (element.hasDateElement())
        composeDateTime(t, "ImplementationGuide", "date", element.getDateElement(), -1);
    if (element.hasPublisherElement())
        composeString(t, "ImplementationGuide", "publisher", element.getPublisherElement(), -1);
    for (int i = 0; i < element.getContact().size(); i++) composeContactDetail(t, "ImplementationGuide", "contact", element.getContact().get(i), i);
    if (element.hasDescriptionElement())
        composeMarkdown(t, "ImplementationGuide", "description", element.getDescriptionElement(), -1);
    for (int i = 0; i < element.getUseContext().size(); i++) composeUsageContext(t, "ImplementationGuide", "useContext", element.getUseContext().get(i), i);
    for (int i = 0; i < element.getJurisdiction().size(); i++) composeCodeableConcept(t, "ImplementationGuide", "jurisdiction", element.getJurisdiction().get(i), i);
    if (element.hasCopyrightElement())
        composeMarkdown(t, "ImplementationGuide", "copyright", element.getCopyrightElement(), -1);
    if (element.hasPackageIdElement())
        composeId(t, "ImplementationGuide", "packageId", element.getPackageIdElement(), -1);
    if (element.hasLicenseElement())
        composeEnum(t, "ImplementationGuide", "license", element.getLicenseElement(), -1);
    for (int i = 0; i < element.getFhirVersion().size(); i++) composeEnum(t, "ImplementationGuide", "fhirVersion", element.getFhirVersion().get(i), i);
    for (int i = 0; i < element.getDependsOn().size(); i++) composeImplementationGuideImplementationGuideDependsOnComponent(t, "ImplementationGuide", "dependsOn", element.getDependsOn().get(i), i);
    for (int i = 0; i < element.getGlobal().size(); i++) composeImplementationGuideImplementationGuideGlobalComponent(t, "ImplementationGuide", "global", element.getGlobal().get(i), i);
    if (element.hasDefinition())
        composeImplementationGuideImplementationGuideDefinitionComponent(t, "ImplementationGuide", "definition", element.getDefinition(), -1);
    if (element.hasManifest())
        composeImplementationGuideImplementationGuideManifestComponent(t, "ImplementationGuide", "manifest", element.getManifest(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Aggregations

ArrayList (java.util.ArrayList)10 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)9 JsonObject (com.google.gson.JsonObject)8 Date (java.util.Date)8 IOException (java.io.IOException)7 FhirContext (ca.uhn.fhir.context.FhirContext)6 JsonArray (com.google.gson.JsonArray)6 HashMap (java.util.HashMap)5 FhirVersionEnum (ca.uhn.fhir.context.FhirVersionEnum)4 IParser (ca.uhn.fhir.parser.IParser)4 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)4 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)4 JsonPrimitive (com.google.gson.JsonPrimitive)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)3 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)3 FHIRException (org.hl7.fhir.exceptions.FHIRException)3 Bundle (org.hl7.fhir.r4.model.Bundle)3 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)3 CascadingDeleteInterceptor (ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor)2