Search in sources :

Example 61 with ImplementationGuide

use of org.hl7.fhir.dstu3.model.ImplementationGuide in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method generate.

public boolean generate(ResourceContext rcontext, ImplementationGuide ig) throws EOperationOutcome, FHIRException, IOException {
    XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
    x.h2().addText(ig.getName());
    x.para().tx("The official URL for this implementation guide is: ");
    x.pre().tx(ig.getUrl());
    addMarkdown(x, ig.getDescription());
    inject(ig, x, NarrativeStatus.GENERATED);
    return true;
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 62 with ImplementationGuide

use of org.hl7.fhir.dstu3.model.ImplementationGuide in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method generate.

public boolean generate(ResourceContext rcontext, ImplementationGuide ig) throws EOperationOutcome, FHIRException, IOException {
    XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
    x.h2().addText(ig.getName());
    x.para().tx("The official URL for this implementation guide is: ");
    x.pre().tx(ig.getUrl());
    addMarkdown(x, ig.getDescription());
    inject(ig, x, NarrativeStatus.GENERATED);
    return true;
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 63 with ImplementationGuide

use of org.hl7.fhir.dstu3.model.ImplementationGuide in project org.hl7.fhir.core by hapifhir.

the class IgLoader method loadIg.

/**
 * @param igs
 * @param binaries
 * @param src Source of the IG
 *
 * @param recursive
 * @throws IOException
 * @throws FHIRException
 *
 * @see IgLoader#loadIgSource(String, boolean, boolean) loadIgSource for detailed description of the src parameter
 */
public void loadIg(List<ImplementationGuide> igs, Map<String, byte[]> binaries, String src, boolean recursive) throws IOException, FHIRException {
    final String explicitFhirVersion;
    final String srcPackage;
    if (src.startsWith("[") && src.indexOf(']', 1) > 1) {
        explicitFhirVersion = src.substring(1, src.indexOf(']', 1));
        srcPackage = src.substring(src.indexOf(']', 1) + 1);
        if (!VersionUtilities.isSupportedVersion(explicitFhirVersion)) {
            throw new FHIRException("Unsupported FHIR Version: " + explicitFhirVersion + " valid versions are " + VersionUtilities.listSupportedVersions());
        }
    } else {
        explicitFhirVersion = null;
        srcPackage = src;
    }
    NpmPackage npm = srcPackage.matches(FilesystemPackageCacheManager.PACKAGE_VERSION_REGEX_OPT) && !new File(srcPackage).exists() ? getPackageCacheManager().loadPackage(srcPackage, null) : null;
    if (npm != null) {
        for (String s : npm.dependencies()) {
            if (!getContext().getLoadedPackages().contains(s)) {
                if (!VersionUtilities.isCorePackage(s)) {
                    loadIg(igs, binaries, s, false);
                }
            }
        }
        System.out.print("  Load " + srcPackage);
        if (!srcPackage.contains("#")) {
            System.out.print("#" + npm.version());
        }
        int count = getContext().loadFromPackage(npm, ValidatorUtils.loaderForVersion(npm.fhirVersion()));
        System.out.println(" - " + count + " resources (" + getContext().clock().milestone() + ")");
    } else {
        System.out.print("  Load " + srcPackage);
        String canonical = null;
        int count = 0;
        Map<String, byte[]> source = loadIgSource(srcPackage, recursive, true);
        String version = Constants.VERSION;
        if (getVersion() != null) {
            version = getVersion();
        }
        if (source.containsKey("version.info")) {
            version = readInfoVersion(source.get("version.info"));
        }
        if (explicitFhirVersion != null) {
            version = explicitFhirVersion;
        }
        for (Map.Entry<String, byte[]> t : source.entrySet()) {
            String fn = t.getKey();
            if (!exemptFile(fn)) {
                Resource r = loadFileWithErrorChecking(version, t, fn);
                if (r != null) {
                    count++;
                    getContext().cacheResource(r);
                    if (r instanceof ImplementationGuide) {
                        canonical = ((ImplementationGuide) r).getUrl();
                        igs.add((ImplementationGuide) r);
                        if (canonical.contains("/ImplementationGuide/")) {
                            Resource r2 = r.copy();
                            ((ImplementationGuide) r2).setUrl(canonical.substring(0, canonical.indexOf("/ImplementationGuide/")));
                            getContext().cacheResource(r2);
                        }
                    }
                }
            }
        }
        if (canonical != null) {
            ValidatorUtils.grabNatives(binaries, source, canonical);
        }
        System.out.println(" - " + count + " resources (" + getContext().clock().milestone() + ")");
    }
}
Also used : ImplementationGuide(org.hl7.fhir.r5.model.ImplementationGuide) NpmPackage(org.hl7.fhir.utilities.npm.NpmPackage) Resource(org.hl7.fhir.r5.model.Resource) FHIRException(org.hl7.fhir.exceptions.FHIRException) IniFile(org.hl7.fhir.utilities.IniFile) TextFile(org.hl7.fhir.utilities.TextFile) HashMap(java.util.HashMap) Map(java.util.Map)

Example 64 with ImplementationGuide

use of org.hl7.fhir.dstu3.model.ImplementationGuide in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeImplementationGuideImplementationGuideManifestComponent.

protected void composeImplementationGuideImplementationGuideManifestComponent(Complex parent, String parentType, String name, ImplementationGuide.ImplementationGuideManifestComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "manifest", name, element, index);
    if (element.hasRenderingElement())
        composeUrl(t, "ImplementationGuide", "rendering", element.getRenderingElement(), -1);
    for (int i = 0; i < element.getResource().size(); i++) composeImplementationGuideManifestResourceComponent(t, "ImplementationGuide", "resource", element.getResource().get(i), i);
    for (int i = 0; i < element.getPage().size(); i++) composeImplementationGuideManifestPageComponent(t, "ImplementationGuide", "page", element.getPage().get(i), i);
    for (int i = 0; i < element.getImage().size(); i++) composeString(t, "ImplementationGuide", "image", element.getImage().get(i), i);
    for (int i = 0; i < element.getOther().size(); i++) composeString(t, "ImplementationGuide", "other", element.getOther().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 65 with ImplementationGuide

use of org.hl7.fhir.dstu3.model.ImplementationGuide 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

ImplementationGuide (org.hl7.fhir.r5.model.ImplementationGuide)16 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)13 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)12 FHIRException (org.hl7.fhir.exceptions.FHIRException)11 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)9 File (java.io.File)8 JsonObject (com.google.gson.JsonObject)7 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)7 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)7 XmlParser (org.hl7.fhir.r5.formats.XmlParser)6 SearchParameter (org.hl7.fhir.r5.model.SearchParameter)5 Gson (com.google.gson.Gson)4 GsonBuilder (com.google.gson.GsonBuilder)4 JsonArray (com.google.gson.JsonArray)4 FileInputStream (java.io.FileInputStream)4 FileOutputStream (java.io.FileOutputStream)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 CanonicalResource (org.hl7.fhir.r5.model.CanonicalResource)4 ValueSet (org.hl7.fhir.r5.model.ValueSet)4